proteus 仿真问题..
时间:10-02
整理:3721RD
点击:
求大神看看。
求别沉
代码是没问题的..
只是个警告而已,应该不影响。 后面不是有个蓝色的问号吗,点开看看提示。
P05没有真的连上,虽然你放了网络,但是可能没对准。
打开了,但是看不懂,里面和其他的P01好像没什么区别.
有了的,这个图我画了好几次了,都是一样包括我用线去对接,还是一样。
搜索
logic contention detected on net
你这可能是代码有问题,端口冲突了。
..这个是我加载了代码之后的提示。代码是我也换了老师提供试了一下,还是一样的问题,老师说是硬件问题。我的其他同学是没有出现这个问题,但是屏幕还是没什么反应,也没有什么提示,
- #include "reg51.h"
- sbit CS1 = P2^6; //右屏片选
- sbit CS2 = P2^5; //左屏片选
- sbit RS = P2^3; //1为数据,0为指令
- sbit RW = P2^2; //1为读操作,0为写操作
- sbit EN = P2^1; //读写使能
- sbit RST = P2^4; //复位,低电平有效
- sbit busy = P0^7;
- #define DataPort P0 //定义数据端口
- #define Dis_On 0x3f //开显示
- #define Dis_Off 0x3e //关显示
- #define Addr_X 0x40 //第0列地址
- #define Addr_Y 0xb8 //第0页地址
- #define Addr_Z 0xc0 //显示起始行——0
- unsigned char code He[32]={/* ---- 河,16X16纵向取模,字节倒序---- */
- 0x00,0x3E,0x22,0xE2,0x22,0x3E,0x00,0x10,0x88,0x57,0x24,0x54,0x8C,0x00,0x00,0x00,
- 0x40,0x7E,0x40,0x3F,0x22,0x22,0x00,0x01,0xFE,0x42,0x42,0x42,0xFE,0x01,0x01,0x00};
- unsigned char code Yuan1[32]={/* -- 源,16X16纵向取模,字节倒序--- */
- 0x10,0x21,0x06,0xE0,0x00,0xFE,0x02,0xF2,0x5A,0x56,0x52,0x52,0x52,0xF2,0x02,0x00,
- 0x04,0xFC,0x03,0x40,0x30,0x0F,0x20,0x11,0x4D,0x81,0x7F,0x01,0x05,0x09,0x30,0x00};
- unsigned char code Zhi[32]={/* ---- 职,16X16纵向取模,字节倒序--- */
- 0x02,0x02,0xFE,0x92,0x92,0xFE,0x02,0x00,0xFE,0x82,0x82,0x82,0x82,0xFE,0x00,0x00,
- 0x10,0x10,0x0F,0x08,0x08,0xFF,0x04,0x44,0x21,0x1C,0x08,0x00,0x04,0x09,0x30,0x00};
- unsigned char code Ye[32]={/* ---- 业,16X16纵向取模,字节倒序---- */
- 0x00,0x10,0x60,0x80,0x00,0xFF,0x00,0x00,0x00,0xFF,0x00,0x80,0x60,0x38,0x10,0x00,
- 0x20,0x20,0x20,0x23,0x21,0x3F,0x20,0x20,0x20,0x3F,0x22,0x21,0x20,0x30,0x20,0x00};
- unsigned char code Ji[32]={/* ---- 技,16X16纵向取模,字节倒序---- */
- 0x08,0x08,0x88,0xFF,0x48,0x28,0x00,0xC8,0x48,0x48,0x7F,0x48,0xC8,0x48,0x08,0x00,
- 0x01,0x41,0x80,0x7F,0x00,0x40,0x40,0x20,0x13,0x0C,0x0C,0x12,0x21,0x60,0x20,0x00};
- unsigned char Shu[32]={/* ---- 术,16X16纵向取模,字节倒序--- */
- 0x10,0x10,0x10,0x10,0x10,0x90,0x50,0xFF,0x50,0x90,0x12,0x14,0x10,0x10,0x10,0x00,
- 0x10,0x10,0x08,0x04,0x02,0x01,0x00,0x7F,0x00,0x00,0x01,0x06,0x0C,0x18,0x08,0x00};
- unsigned char Xue[32]={/* ---- 学,16X16纵向取模,字节倒序--- */
- 0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x57,0x32,0x10,0x00,
- 0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x00};
- unsigned char code Yuan2[32]={/* --- 院,16X16纵向取模,字节倒序-- */
- 0xFE,0x02,0x32,0x4A,0x86,0x0C,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0x0C,0x04,0x00,
- 0xFF,0x00,0x02,0x04,0x83,0x41,0x31,0x0F,0x01,0x01,0x7F,0x81,0x81,0x81,0xF1,0x00};
- unsigned char code Dian[32]={/* --- 电,16X16纵向取模,字节倒序--- */
- 0x00,0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xF8,0x00,0x00,0x00,
- 0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0x3F,0x44,0x44,0x44,0x44,0x4F,0x40,0x70,0x00};
- unsigned char code Xin[32]={/* ---- 信,16X16纵向取模,字节倒序--- */
- 0x80,0x40,0x30,0xFC,0x07,0x0A,0xA8,0xA8,0xA9,0xAE,0xAA,0xA8,0xA8,0x08,0x08,0x00,
- 0x00,0x00,0x00,0x7F,0x00,0x00,0x7E,0x22,0x22,0x22,0x22,0x22,0x7E,0x00,0x00,0x00};
- unsigned char code Huan[32]={/* ---- 欢,16X16纵向取模,字节倒序-- */
- 0x14,0x24,0x44,0x84,0x64,0x1C,0x20,0x18,0x0F,0xE8,0x08,0x08,0x28,0x18,0x08,0x00,
- 0x20,0x10,0x4C,0x43,0x43,0x2C,0x20,0x10,0x0C,0x03,0x06,0x18,0x30,0x60,0x20,0x00};
- unsigned char code Ying[32]={/* --- 迎,16X16纵向取模,字节倒序--- */
- 0x40,0x41,0xCE,0x04,0x00,0xFC,0x04,0x02,0x02,0xFC,0x04,0x04,0x04,0xFC,0x00,0x00,
- 0x40,0x20,0x1F,0x20,0x40,0x47,0x42,0x41,0x40,0x5F,0x40,0x42,0x44,0x43,0x40,0x00};
- unsigned char code Nin[32]={/* ---- 您,16X16纵向取模,字节倒序--- */
- 0x80,0x40,0x30,0xFC,0x03,0x90,0x68,0x06,0x04,0xF4,0x04,0x24,0x44,0x8C,0x04,0x00,
- 0x00,0x20,0x38,0x03,0x38,0x40,0x40,0x49,0x52,0x41,0x40,0x70,0x00,0x09,0x30,0x00};
- unsigned char code BZ[288]={/* --- 校徽,48X48纵向取模,字节倒序-- */
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF0,0xF8,0xF8,
- 0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8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0x00,0x00,0x00,0x00,
- 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x0F,0x1F,0x1F,
- 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
- 0x1F,0x1F,0x0F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
- //*****************************************************************************
- void DelayUs(unsigned int t) //晶振12M,大致延时长度1us
- { while(--t);
- }
- //*****************************************************************************
- void DelayMs(unsigned char t)
- { while(t--) //大致延时1*t ms
- { DelayUs(1000);
- }
- }
- //*****************************************************************************
- void Check_Busy() //读状态,检测忙位
- { EN=0;
- RW=1;
- RS=0;
- DelayUs(1);
- EN=1;
- DataPort=0xff;
- while(!busy);
- EN=0;
- }
- //*****************************************************************************
- void Send_Order(unsigned char Order) //写指令
- { Check_Busy(); //调检测忙位函数
- EN=0; //根据时序设置EN、RW、RS状态
- RW=0;
- RS=0;
- DelayUs(1);
- EN=1;
- DataPort=Order; //写入指令
- DelayUs(2);
- EN=0; //EN信号下降沿,指令被送出
- }
- //*****************************************************************************
- void Send_Data(unsigned char dat) //写数据
- { Check_Busy(); //调检测忙位函数
- EN=0; //根据时序设置EN、RW、RS状态
- RW=0;
- RS=1;
- DelayUs(1);
- EN=1;
- DataPort=dat; //写入数据
- DelayUs(2);
- EN=0; //EN信号下降沿,数据被送出
- }
- //*****************************************************************************
- void LCD_CSX(unsigned char number) //选屏
- { switch(number)
- { case 0: CS1=0,CS2=0;break; //全屏
- case 1: CS1=0,CS2=1;break; //左屏
- case 2: CS1=1,CS2=0;break; //右屏
- }
- }
- //*****************************************************************************
- void Clear_Screen(unsigned char num) //清屏
- { unsigned char m, n;
- LCD_CSX(num); //选屏
- for(m=0;m<8;m++) //共8页
- { Send_Order(Addr_Y+m); //发送页地址
- Send_Order(Addr_X); //发送列地址,列地址为自增
- for(n=0;n<64;n++) //共64列
- { Send_Data(0x00); //写0,清除显示
- }
- }
- }
- /******************************************************************************
- 发送汉字数据
- num:选屏,范围0~2;x:列地址,范围0~127;y:起始页,范围0~7;*Spdata:显示的汉字代码
- ******************************************************************************/
- void Send_Ndata(unsigned char num,unsigned char X,unsigned char Y,const unsigned char *Spdata)
- { unsigned char m, n;
- LCD_CSX(num); //选屏
- for(m=0;m<2;m++) //共2页
- { Send_Order(Addr_Y+Y+m); //发送页地址
- Send_Order(Addr_X+X); //发送列地址
- for(n=0;n<16;n++) //发送列数据,共32列
- { Send_Data(Spdata[m*16+n]);
- }
- }
- }
- /******************************************************************************
- 发送图片数据
- num:选屏,范围0~2;x:列地址,范围0~63;y:起始页,范围0~7;*Spdata:显示的内容
- ******************************************************************************/
- void Send_photo(unsigned char num,unsigned char X,unsigned char Y,const unsigned char *Spdata)
- { unsigned char m, n;
- LCD_CSX(num); //选屏
- for(m=0;m<6;m++) //共6页
- { Send_Order(Addr_Y+Y+m); //发送页地址
- Send_Order(Addr_X+X); //发送列地址
- for(n=0;n<48;n++) //发送列数据,共32列
- { Send_Data(Spdata[m*48+n]);
- }
- }
- }
- /******************************************************************************
- 发送点数据
- num:选屏,范围0~2;x:列地址,范围0~63;y:字型代码;da:点数据
- ******************************************************************************/
- void Send_dot(unsigned char num,unsigned char X,unsigned char Y,unsigned char da)
- { LCD_CSX(num); //选屏
- Send_Order(Addr_Y+Y); //发送页地址
- Send_Order(Addr_X+X); //发送列地址
- Send_Data(da);
- }
- //*****************************************************************************
- void Init_Lcd() //初始化12864液晶屏
- { RST=0; //复位
- DelayMs(2);
- RST=1;
- DelayMs(2);
- Send_Order(Dis_Off); //关显示
- Clear_Screen(1); //清屏(不能整屏同时清屏)
- Clear_Screen(2); //清屏
- Send_Order(Addr_Z); //显示起始行为0
- Send_Order(Dis_On); //开显示
- }
- //*****************************************************************************
- void main()
- { Init_Lcd();
- /* === 显示“河源职业技术学院” === */
- Send_Ndata(1,0,0,He);
- Send_Ndata(1,16,0,Yuan1);
- Send_Ndata(1,32,0,Zhi);
- Send_Ndata(1,48,0,Ye);
- DelayMs(5);
- Send_Ndata(2,0,0,Ji);
- Send_Ndata(2,16,0,Shu);
- Send_Ndata(2,32,0,Xue);
- Send_Ndata(2,48,0,Yuan2);
- /* ======= 显示“电信学院” ======= */
- Send_Ndata(1,0,2,Dian);
- Send_Ndata(1,16,2,Xin);
- Send_Ndata(1,32,2,Xue);
- Send_Ndata(1,48,2,Yuan2);
- /* ======== 显示“欢迎您” ======== */
- Send_Ndata(1,8,4,Huan);
- Send_Ndata(1,24,4,Ying);
- Send_Ndata(1,40,4,Nin);
- /* ========= 显示“校徽” =========*/
- Send_photo(2,8,2,BZ);
- /* ======显示“某个像素点” =======*/
- Send_dot(1,0,7,0x01);
- while(1);
- }
搞定了,是代码问题,是检查忙那里的问题,而且还有端口定义位置反了...
应该是是状态判断那里卡住了..