微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 嵌入式设计讨论 > MCU和单片机设计讨论 > proteus 仿真问题..

proteus 仿真问题..

时间:10-02 整理:3721RD 点击:
求大神看看。


求别沉

代码是没问题的..

只是个警告而已,应该不影响。 后面不是有个蓝色的问号吗,点开看看提示。

P05没有真的连上,虽然你放了网络,但是可能没对准。

打开了,但是看不懂,里面和其他的P01好像没什么区别.

有了的,这个图我画了好几次了,都是一样包括我用线去对接,还是一样。

搜索
logic contention detected on net  
你这可能是代码有问题,端口冲突了。

..这个是我加载了代码之后的提示。代码是我也换了老师提供试了一下,还是一样的问题,老师说是硬件问题。我的其他同学是没有出现这个问题,但是屏幕还是没什么反应,也没有什么提示,

  1. #include "reg51.h"
  2. sbit CS1 = P2^6;                        //右屏片选
  3. sbit CS2 = P2^5;                        //左屏片选
  4. sbit RS  = P2^3;                        //1为数据,0为指令
  5. sbit RW  = P2^2;                        //1为读操作,0为写操作
  6. sbit EN  = P2^1;                        //读写使能
  7. sbit RST = P2^4;                        //复位,低电平有效
  8. sbit busy = P0^7;
  9. #define DataPort         P0      //定义数据端口
  10. #define Dis_On 0x3f                        //开显示
  11. #define Dis_Off 0x3e                //关显示
  12. #define Addr_X 0x40                        //第0列地址
  13. #define Addr_Y 0xb8                        //第0页地址
  14. #define Addr_Z 0xc0                        //显示起始行——0

  15. unsigned char code He[32]={/* ---- 河,16X16纵向取模,字节倒序---- */
  16. 0x00,0x3E,0x22,0xE2,0x22,0x3E,0x00,0x10,0x88,0x57,0x24,0x54,0x8C,0x00,0x00,0x00,
  17. 0x40,0x7E,0x40,0x3F,0x22,0x22,0x00,0x01,0xFE,0x42,0x42,0x42,0xFE,0x01,0x01,0x00};

  18. unsigned char code Yuan1[32]={/* -- 源,16X16纵向取模,字节倒序--- */
  19. 0x10,0x21,0x06,0xE0,0x00,0xFE,0x02,0xF2,0x5A,0x56,0x52,0x52,0x52,0xF2,0x02,0x00,
  20. 0x04,0xFC,0x03,0x40,0x30,0x0F,0x20,0x11,0x4D,0x81,0x7F,0x01,0x05,0x09,0x30,0x00};

  21. unsigned char code Zhi[32]={/* ---- 职,16X16纵向取模,字节倒序--- */
  22. 0x02,0x02,0xFE,0x92,0x92,0xFE,0x02,0x00,0xFE,0x82,0x82,0x82,0x82,0xFE,0x00,0x00,
  23. 0x10,0x10,0x0F,0x08,0x08,0xFF,0x04,0x44,0x21,0x1C,0x08,0x00,0x04,0x09,0x30,0x00};

  24. unsigned char code Ye[32]={/* ---- 业,16X16纵向取模,字节倒序---- */
  25. 0x00,0x10,0x60,0x80,0x00,0xFF,0x00,0x00,0x00,0xFF,0x00,0x80,0x60,0x38,0x10,0x00,
  26. 0x20,0x20,0x20,0x23,0x21,0x3F,0x20,0x20,0x20,0x3F,0x22,0x21,0x20,0x30,0x20,0x00};

  27. unsigned char code Ji[32]={/* ---- 技,16X16纵向取模,字节倒序---- */
  28. 0x08,0x08,0x88,0xFF,0x48,0x28,0x00,0xC8,0x48,0x48,0x7F,0x48,0xC8,0x48,0x08,0x00,
  29. 0x01,0x41,0x80,0x7F,0x00,0x40,0x40,0x20,0x13,0x0C,0x0C,0x12,0x21,0x60,0x20,0x00};

  30. unsigned char Shu[32]={/* ---- 术,16X16纵向取模,字节倒序--- */
  31. 0x10,0x10,0x10,0x10,0x10,0x90,0x50,0xFF,0x50,0x90,0x12,0x14,0x10,0x10,0x10,0x00,
  32. 0x10,0x10,0x08,0x04,0x02,0x01,0x00,0x7F,0x00,0x00,0x01,0x06,0x0C,0x18,0x08,0x00};

  33. unsigned char Xue[32]={/* ---- 学,16X16纵向取模,字节倒序--- */
  34. 0x40,0x30,0x10,0x12,0x5C,0x54,0x50,0x51,0x5E,0xD4,0x50,0x18,0x57,0x32,0x10,0x00,
  35. 0x00,0x02,0x02,0x02,0x02,0x02,0x42,0x82,0x7F,0x02,0x02,0x02,0x02,0x02,0x02,0x00};

  36. unsigned char code Yuan2[32]={/* --- 院,16X16纵向取模,字节倒序-- */
  37. 0xFE,0x02,0x32,0x4A,0x86,0x0C,0x24,0x24,0x25,0x26,0x24,0x24,0x24,0x0C,0x04,0x00,
  38. 0xFF,0x00,0x02,0x04,0x83,0x41,0x31,0x0F,0x01,0x01,0x7F,0x81,0x81,0x81,0xF1,0x00};

  39. unsigned char code Dian[32]={/* --- 电,16X16纵向取模,字节倒序--- */
  40. 0x00,0x00,0xF8,0x48,0x48,0x48,0x48,0xFF,0x48,0x48,0x48,0x48,0xF8,0x00,0x00,0x00,
  41. 0x00,0x00,0x0F,0x04,0x04,0x04,0x04,0x3F,0x44,0x44,0x44,0x44,0x4F,0x40,0x70,0x00};

  42. unsigned char code Xin[32]={/* ---- 信,16X16纵向取模,字节倒序--- */
  43. 0x80,0x40,0x30,0xFC,0x07,0x0A,0xA8,0xA8,0xA9,0xAE,0xAA,0xA8,0xA8,0x08,0x08,0x00,
  44. 0x00,0x00,0x00,0x7F,0x00,0x00,0x7E,0x22,0x22,0x22,0x22,0x22,0x7E,0x00,0x00,0x00};

  45. unsigned char code Huan[32]={/* ---- 欢,16X16纵向取模,字节倒序-- */
  46. 0x14,0x24,0x44,0x84,0x64,0x1C,0x20,0x18,0x0F,0xE8,0x08,0x08,0x28,0x18,0x08,0x00,
  47. 0x20,0x10,0x4C,0x43,0x43,0x2C,0x20,0x10,0x0C,0x03,0x06,0x18,0x30,0x60,0x20,0x00};

  48. unsigned char code Ying[32]={/* --- 迎,16X16纵向取模,字节倒序--- */
  49. 0x40,0x41,0xCE,0x04,0x00,0xFC,0x04,0x02,0x02,0xFC,0x04,0x04,0x04,0xFC,0x00,0x00,
  50. 0x40,0x20,0x1F,0x20,0x40,0x47,0x42,0x41,0x40,0x5F,0x40,0x42,0x44,0x43,0x40,0x00};

  51. unsigned char code Nin[32]={/* ---- 您,16X16纵向取模,字节倒序--- */
  52. 0x80,0x40,0x30,0xFC,0x03,0x90,0x68,0x06,0x04,0xF4,0x04,0x24,0x44,0x8C,0x04,0x00,
  53. 0x00,0x20,0x38,0x03,0x38,0x40,0x40,0x49,0x52,0x41,0x40,0x70,0x00,0x09,0x30,0x00};

  54. unsigned char code BZ[288]={/* --- 校徽,48X48纵向取模,字节倒序-- */
  55. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0xE0,0xF0,0xF8,0xF8,
  56. 0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,0xF8,
  57. 0xF8,0xF8,0xF0,0xE0,0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  58. 0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0xE0,0xE0,0x8C,0x8F,0x8F,0x8F,0x0F,0x0F,0x0F,
  59. 0x0F,0x0F,0x0F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x0F,0x0F,0x0F,
  60. 0x0F,0x0F,0x0F,0x8F,0x8F,0x8F,0x8C,0xE0,0xE0,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,
  61. 0x00,0x00,0xC0,0xF0,0xFC,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
  62. 0x00,0x00,0x00,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x3F,0x00,0x00,0x00,
  63. 0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFC,0xF0,0xC0,0x00,0x00,
  64. 0x00,0x00,0x01,0x07,0x1F,0x7F,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x00,0x00,0x00,
  65. 0x00,0x00,0x00,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0xFE,0x00,0x00,0x00,
  66. 0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0x1F,0x07,0x01,0x00,0x00,
  67. 0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x03,0x03,0x30,0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,
  68. 0xF0,0xF0,0xF0,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0xF0,0xF0,
  69. 0xF0,0xF0,0xF0,0xF0,0xF0,0xF0,0x30,0x03,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,
  70. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x07,0x0F,0x1F,0x1F,
  71. 0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,0x1F,
  72. 0x1F,0x1F,0x0F,0x07,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

  73. //*****************************************************************************
  74. void DelayUs(unsigned int t)                   //晶振12M,大致延时长度1us
  75. {         while(--t);                               
  76. }
  77. //*****************************************************************************
  78. void DelayMs(unsigned char t)
  79. {        while(t--)                                         //大致延时1*t ms
  80.         {        DelayUs(1000);
  81.         }
  82. }
  83. //*****************************************************************************
  84. void Check_Busy()                                 //读状态,检测忙位
  85. {        EN=0;
  86.         RW=1;
  87.         RS=0;
  88.         DelayUs(1);
  89.         EN=1;
  90.         DataPort=0xff;
  91.         while(!busy);
  92.         EN=0;                               
  93. }
  94. //*****************************************************************************
  95. void Send_Order(unsigned char Order)        //写指令
  96. {        Check_Busy();                                                 //调检测忙位函数
  97.         EN=0;                                                                //根据时序设置EN、RW、RS状态
  98.         RW=0;                                               
  99.         RS=0;                                               
  100.         DelayUs(1);                                                       
  101.         EN=1;                                                               
  102.         DataPort=Order;                                                //写入指令       
  103.         DelayUs(2);       
  104.         EN=0;                                                                //EN信号下降沿,指令被送出       
  105. }
  106. //*****************************************************************************
  107. void Send_Data(unsigned char dat)           //写数据
  108. {          Check_Busy();                                           //调检测忙位函数
  109.         EN=0;                                                           //根据时序设置EN、RW、RS状态
  110.         RW=0;                                               
  111.         RS=1;                                               
  112.         DelayUs(1);               
  113.         EN=1;
  114.         DataPort=dat;                                                //写入数据                               
  115.         DelayUs(2);
  116.         EN=0;                                                                //EN信号下降沿,数据被送出
  117. }
  118. //*****************************************************************************
  119. void LCD_CSX(unsigned char number)                //选屏
  120. {        switch(number)
  121.         {          case 0: CS1=0,CS2=0;break;                //全屏
  122.                 case 1: CS1=0,CS2=1;break;                //左屏
  123.                 case 2: CS1=1,CS2=0;break;                //右屏
  124.         }
  125. }
  126. //*****************************************************************************
  127. void Clear_Screen(unsigned char num)        //清屏
  128. {        unsigned char m, n;
  129.         LCD_CSX(num);                                                //选屏
  130.         for(m=0;m<8;m++)                                        //共8页                       
  131.         {        Send_Order(Addr_Y+m);                        //发送页地址       
  132.                 Send_Order(Addr_X);                                //发送列地址,列地址为自增       
  133.                 for(n=0;n<64;n++)                                //共64列
  134.                 {  Send_Data(0x00);                                //写0,清除显示
  135.                 }
  136.         }       
  137. }
  138. /******************************************************************************
  139.                                  发送汉字数据
  140. num:选屏,范围0~2;x:列地址,范围0~127;y:起始页,范围0~7;*Spdata:显示的汉字代码
  141. ******************************************************************************/
  142. void Send_Ndata(unsigned char num,unsigned char X,unsigned char Y,const unsigned char *Spdata)
  143. {        unsigned char m, n;
  144.         LCD_CSX(num);                                                //选屏
  145.         for(m=0;m<2;m++)                                        //共2页
  146.         {        Send_Order(Addr_Y+Y+m);                        //发送页地址
  147.                 Send_Order(Addr_X+X);                        //发送列地址               
  148.                 for(n=0;n<16;n++)                                //发送列数据,共32列
  149.                 {        Send_Data(Spdata[m*16+n]);
  150.                 }
  151.         }
  152. }
  153. /******************************************************************************
  154.                                 发送图片数据
  155. num:选屏,范围0~2;x:列地址,范围0~63;y:起始页,范围0~7;*Spdata:显示的内容
  156. ******************************************************************************/
  157. void Send_photo(unsigned char num,unsigned char X,unsigned char Y,const unsigned char *Spdata)
  158. {        unsigned char m, n;
  159.         LCD_CSX(num);                                                //选屏
  160.         for(m=0;m<6;m++)                                        //共6页
  161.         {        Send_Order(Addr_Y+Y+m);                        //发送页地址
  162.                 Send_Order(Addr_X+X);                        //发送列地址               
  163.                 for(n=0;n<48;n++)                                //发送列数据,共32列
  164.                 {        Send_Data(Spdata[m*48+n]);
  165.                 }
  166.         }
  167. }
  168. /******************************************************************************
  169.                                 发送点数据
  170. num:选屏,范围0~2;x:列地址,范围0~63;y:字型代码;da:点数据
  171. ******************************************************************************/
  172. void Send_dot(unsigned char num,unsigned char X,unsigned char Y,unsigned char da)
  173. {        LCD_CSX(num);                                                //选屏
  174.         Send_Order(Addr_Y+Y);                                //发送页地址
  175.         Send_Order(Addr_X+X);                                //发送列地址               
  176.         Send_Data(da);
  177. }
  178. //*****************************************************************************
  179. void Init_Lcd()                                                         //初始化12864液晶屏
  180. {        RST=0;                                                                //复位
  181.         DelayMs(2);
  182.         RST=1;
  183.         DelayMs(2);
  184.         Send_Order(Dis_Off);                                //关显示
  185.         Clear_Screen(1);                                        //清屏(不能整屏同时清屏)
  186.         Clear_Screen(2);                                        //清屏
  187.         Send_Order(Addr_Z);                                        //显示起始行为0
  188.         Send_Order(Dis_On);                                        //开显示
  189. }
  190. //*****************************************************************************
  191. void main()
  192. {        Init_Lcd();
  193. /* === 显示“河源职业技术学院” === */
  194.         Send_Ndata(1,0,0,He);
  195.         Send_Ndata(1,16,0,Yuan1);
  196.         Send_Ndata(1,32,0,Zhi);
  197.         Send_Ndata(1,48,0,Ye);
  198.         DelayMs(5);
  199.         Send_Ndata(2,0,0,Ji);
  200.         Send_Ndata(2,16,0,Shu);
  201.         Send_Ndata(2,32,0,Xue);
  202.         Send_Ndata(2,48,0,Yuan2);
  203. /* ======= 显示“电信学院” ======= */
  204.         Send_Ndata(1,0,2,Dian);
  205.         Send_Ndata(1,16,2,Xin);
  206.         Send_Ndata(1,32,2,Xue);
  207.         Send_Ndata(1,48,2,Yuan2);
  208. /* ======== 显示“欢迎您” ======== */
  209.         Send_Ndata(1,8,4,Huan);
  210.         Send_Ndata(1,24,4,Ying);
  211.         Send_Ndata(1,40,4,Nin);
  212. /* ========= 显示“校徽” =========*/
  213.         Send_photo(2,8,2,BZ);
  214. /* ======显示“某个像素点” =======*/
  215.         Send_dot(1,0,7,0x01);                                       
  216.         while(1);
  217. }

复制代码

搞定了,是代码问题,是检查忙那里的问题,而且还有端口定义位置反了...

应该是是状态判断那里卡住了..

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top