找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 1900|回复: 3
收起左侧

oled编译出现错误,一直不知道怎么解决,想请问一下大家

[复制链接]
ID:608920 发表于 2020-1-26 21:24 | 显示全部楼层 |阅读模式
代码如下,是商家那边给我的例程,我想通过改例程来使用,但是我解决不了编译器报错问题,明明代码的位操作没有问题,就是无法编译
TIM截图20200126212401.png

  1. //Drive_IC:SSD1306
  2. //=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

  3. //#include <at89x51.h>
  4. #include <reg52.h>
  5. #include "intrins.h"



  6. #define Uchar unsigned char
  7. #define Uint  unsigned int
  8. #define Ulong unsigned long
  9. #define uchar unsigned char
  10. #define uint  unsigned int


  11. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  12. //  Pin Definition
  13. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=



  14. //#define SCL3        P3^1                                // Serial Clock Input
  15. //#define SDA3        P3^2                                // Serial Data Input  
  16. sbit SCL3=P3^1;
  17. sbit SDA3=P3^2;

  18. code color13[]={
  19. /*------------------------------------------------------------------------------
  20. ;  源文件 / 文字 : C:\Documents and Settings\Administrator\桌面\新建文件夹 (2)\logo.bmp字模
  21. ;  宽×高(像素): 128×64
  22. ------------------------------------------------------------------------------*/
  23. //0x80,0x40,0x10,//宽的像素数,高的像素数,宽的字节数,参数设置可选
  24. 0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  25. 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  26. 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  27. 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  28. 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  29. 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  30. 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  31. 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,
  32. 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  33. 0x00,0x00,0x00,0x20,0x44,0x08,0x00,0x18,0x48,0x28,0xC8,0x08,0x28,0x48,0x18,0x00,
  34. 0x40,0x40,0xFC,0x40,0x40,0xFC,0x00,0x00,0xF8,0x00,0x00,0xFC,0x00,0x40,0x40,0xA0,
  35. 0x90,0x88,0x84,0x88,0x90,0x20,0x40,0x40,0x00,0x00,0x40,0x44,0xD8,0x20,0xF0,0xAC,
  36. 0xA8,0xE8,0xB8,0xA8,0xE0,0x00,0x00,0x00,0xC0,0x7C,0x54,0x54,0x54,0x54,0x54,0x54,
  37. 0x7C,0x40,0x40,0x00,0x00,0xF0,0x90,0x90,0x90,0xFC,0x90,0x90,0x90,0xF0,0x00,0x00,
  38. 0x00,0x80,0x88,0x88,0x88,0x88,0x88,0xE8,0xA8,0x98,0x8C,0x88,0x80,0x00,0x00,0x00,
  39. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
  40. 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  41. 0x00,0x00,0x00,0x04,0x3E,0x01,0x10,0x11,0x09,0x05,0x3F,0x05,0x09,0x11,0x11,0x00,
  42. 0x08,0x18,0x0F,0x24,0x14,0x0F,0x00,0x00,0x0F,0x00,0x00,0x3F,0x00,0x20,0x22,0x2A,
  43. 0x32,0x22,0x3F,0x22,0x32,0x2A,0x22,0x20,0x00,0x00,0x20,0x10,0x0F,0x10,0x28,0x24,
  44. 0x23,0x20,0x2F,0x28,0x2A,0x2C,0x00,0x30,0x0F,0x04,0x3D,0x25,0x15,0x15,0x0D,0x15,
  45. 0x2D,0x24,0x24,0x00,0x00,0x07,0x04,0x04,0x04,0x1F,0x24,0x24,0x24,0x27,0x20,0x38,
  46. 0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  47. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
  48. 0xFF,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
  49. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
  50. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
  51. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
  52. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
  53. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
  54. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
  55. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xFF,
  56. 0xFF,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  57. 0x01,0x01,0x01,0x81,0x41,0x21,0x21,0x61,0x01,0x01,0x21,0xE1,0xE1,0x01,0xE1,0xE1,
  58. 0x21,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x21,0xE1,0x21,0x21,0x21,0x61,0x01,0x01,
  59. 0x21,0x21,0xE1,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  60. 0x01,0x01,0x01,0x01,0x01,0x01,0xC1,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  61. 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  62. 0x01,0x01,0x01,0x21,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,
  63. 0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0xFF,
  64. 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  65. 0x00,0x00,0x00,0x0F,0x10,0x20,0x24,0x1C,0x04,0x00,0x20,0x3F,0x01,0x3E,0x01,0x3F,
  66. 0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x3F,0x22,0x22,0x27,0x30,0x00,0x00,
  67. 0x20,0x20,0x3F,0x20,0x20,0x00,0x00,0x1E,0x25,0x25,0x25,0x16,0x00,0x00,0x1E,0x21,
  68. 0x21,0x21,0x13,0x00,0x01,0x01,0x1F,0x21,0x21,0x00,0x00,0x00,0x21,0x3F,0x22,0x21,
  69. 0x01,0x00,0x00,0x1E,0x21,0x21,0x21,0x1E,0x00,0x21,0x3F,0x22,0x01,0x01,0x3E,0x20,
  70. 0x00,0x21,0x21,0x3F,0x20,0x20,0x00,0x00,0x1E,0x21,0x21,0x21,0x13,0x00,0x00,0x00,
  71. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
  72. 0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  73. 0x00,0x00,0x00,0xF0,0x08,0x04,0x04,0x04,0x0C,0x00,0xF0,0x08,0x04,0x04,0x08,0xF0,
  74. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80,0x80,0x00,0x00,0x00,0x00,0x00,
  75. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0xFC,0x04,0x00,
  76. 0x00,0x00,0x00,0x00,0x0C,0x04,0xFC,0x04,0x0C,0x00,0x04,0xFC,0x04,0x04,0x08,0xF0,
  77. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  78. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  79. 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
  80. 0xFF,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
  81. 0x80,0x80,0x80,0x81,0x82,0x84,0x84,0x84,0x82,0x80,0x81,0x82,0x84,0x84,0x82,0x81,
  82. 0x80,0x80,0x86,0x86,0x80,0x80,0x80,0x80,0x80,0x85,0x83,0x80,0x80,0x80,0x80,0x80,
  83. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x84,0x87,0x84,0x84,
  84. 0x84,0x86,0x80,0x80,0x80,0x84,0x87,0x84,0x80,0x80,0x84,0x87,0x84,0x84,0x82,0x81,
  85. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
  86. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,
  87. 0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0xFF,
  88. };

  89. code color14[]={
  90. /*--  调入了一幅图像:F:\工作\8051\OLED1\abcd.bmp  --*/
  91. /*--  宽度x高度=128x64  --*/
  92. 0x00,0x00,0x00,0xF0,0x08,0x04,0x04,0x08,0xF0,0x00,0x04,0xFC,0x04,0x00,0x00,0x00,
  93. 0x00,0x04,0xFC,0x44,0x44,0xE4,0x0C,0x00,0x04,0xFC,0x04,0x04,0x08,0xF0,0x00,0xA8,
  94. 0xAE,0x98,0xFF,0xAC,0x8A,0x10,0xFC,0x0B,0x88,0x78,0x08,0x00,0x88,0x86,0x92,0x92,
  95. 0x92,0x92,0xD3,0xB2,0x92,0x82,0x8A,0x86,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
  96. 0x00,0x00,0x00,0x00,0x00,0x00,0x82,0x82,0xF2,0x92,0x97,0x92,0xFA,0x92,0x97,0xF2,
  97. 0x82,0x82,0x00,0x04,0x04,0x04,0x1C,0x64,0x85,0x06,0xC4,0x3C,0x04,0x04,0x04,0x00,
  98. 0x00,0x80,0x3E,0x2A,0xEA,0x2A,0x2A,0xEA,0x2A,0x3F,0x82,0x00,0x00,0x00,0x10,0x12,
  99. 0xD2,0x12,0x12,0xF2,0x12,0x52,0x93,0x1A,0x10,0x00,0x00,0xC0,0xC0,0x00,0x00,0x00,
  100. 0x00,0x00,0x00,0x01,0xC2,0x04,0xC4,0x02,0x81,0x40,0x44,0x47,0x84,0x04,0x04,0x06,
  101. 0x00,0x04,0x07,0x04,0x04,0x84,0xC6,0x00,0x04,0x07,0x84,0x44,0x42,0x41,0x80,0x08,
  102. 0x88,0x45,0x42,0x42,0x85,0x08,0x04,0x03,0x82,0xC4,0x08,0x00,0xC0,0x40,0x40,0x40,
  103. 0x40,0x08,0x8F,0x40,0x40,0xC0,0x00,0x00,0xC0,0x40,0x41,0xC2,0x46,0x00,0x80,0x40,
  104. 0x40,0x40,0x80,0x00,0x80,0x40,0x48,0x48,0x88,0x04,0x82,0x41,0x40,0x41,0x82,0x04,
  105. 0x08,0x08,0x00,0x08,0x08,0x08,0x44,0xC4,0x02,0x01,0x02,0x04,0x04,0x08,0x08,0x00,
  106. 0x08,0x08,0x09,0x0A,0x0F,0x48,0xC8,0x0F,0x0A,0x09,0xCC,0x08,0x00,0x04,0x42,0xC1,
  107. 0x40,0x40,0x88,0x0F,0x80,0x40,0x40,0x41,0xC6,0x00,0x40,0xC6,0x46,0x40,0x80,0x00,
  108. 0x00,0x00,0x09,0x3D,0x0B,0x3D,0x0B,0x09,0x03,0x34,0x24,0x24,0x1F,0x00,0x00,0x00,
  109. 0x21,0x00,0x00,0x00,0x00,0x20,0x3F,0x20,0x00,0x00,0x31,0x28,0x24,0x22,0x21,0x00,
  110. 0x10,0x20,0x22,0x22,0x1D,0x00,0x04,0x0B,0x08,0x3F,0x28,0x00,0x13,0x22,0x22,0x22,
  111. 0x1C,0x00,0x1F,0x22,0x22,0x22,0x1C,0x00,0x00,0x00,0x3E,0x01,0x00,0x00,0x1D,0x22,
  112. 0x22,0x22,0x1D,0x00,0x03,0x34,0x24,0x24,0x1F,0x00,0x1F,0x20,0x20,0x20,0x1F,0x00,
  113. 0x00,0x14,0x2A,0x2A,0x3C,0x20,0x00,0x3F,0x22,0x22,0x1C,0x00,0x00,0x1C,0x22,0x22,
  114. 0x26,0x00,0x00,0x1C,0x22,0x22,0x3F,0x20,0x20,0x3E,0x09,0x0F,0x38,0x20,0x20,0x3F,
  115. 0x22,0x22,0x1D,0x00,0x1F,0x20,0x20,0x20,0x10,0x00,0x20,0x3F,0x20,0x20,0x1F,0x00,
  116. 0x00,0x00,0x88,0xE8,0x9E,0xC8,0xBE,0x88,0x00,0x00,0x00,0x04,0xFE,0x00,0x00,0x00,
  117. 0x00,0xFC,0x02,0x02,0x02,0xFC,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,
  118. 0x04,0xFE,0x00,0x00,0x00,0x00,0x0C,0x82,0x42,0x22,0x1C,0x00,0x00,0x04,0x02,0x12,
  119. 0x12,0xEC,0x00,0x40,0xB0,0x88,0x84,0xFE,0x00,0x00,0x00,0xBE,0x12,0x12,0x12,0xE2,
  120. 0x00,0x00,0xF8,0x24,0x12,0x12,0xE6,0x00,0x00,0x20,0x90,0x50,0x50,0xE0,0x00,0x02,
  121. 0xFE,0x10,0x10,0x10,0xE0,0x00,0x00,0xE0,0x10,0x10,0x10,0x30,0x00,0x00,0xE0,0x10,
  122. 0x10,0x12,0xFE,0x00,0x00,0x80,0x78,0x46,0x78,0x80,0x00,0x02,0xFE,0x12,0x12,0x12,
  123. 0xEC,0x00,0xF8,0x04,0x02,0x02,0x02,0x06,0x00,0x02,0xFE,0x02,0x02,0x04,0xF8,0x00,
  124. 0x40,0xC0,0x78,0x43,0xC0,0x7B,0x40,0x00,0x00,0x10,0x10,0xFA,0x03,0x02,0x00,0x00,
  125. 0x00,0x71,0x0A,0x0A,0x0A,0x89,0x70,0x00,0x00,0x03,0x03,0xC0,0xC0,0x00,0x00,0x00,
  126. 0x02,0x13,0x12,0xF8,0x00,0x00,0x03,0x02,0x02,0x72,0x0A,0x08,0x08,0x89,0x72,0x02,
  127. 0x02,0x31,0x08,0x88,0x88,0x48,0x32,0x03,0x02,0x00,0xC0,0x21,0x12,0xFA,0x02,0x01,
  128. 0x00,0xF8,0x09,0x8A,0x8A,0x0A,0x09,0x00,0x00,0xE1,0x12,0x8A,0x8A,0x1B,0x02,0x00,
  129. 0x03,0x02,0x82,0x82,0x81,0x80,0x00,0x01,0x0A,0xFA,0x02,0x81,0x80,0x00,0x01,0x02,
  130. 0x02,0x02,0x03,0x82,0x82,0x83,0x02,0x00,0x02,0x03,0xC2,0x3A,0xE3,0x02,0x02,0x02,
  131. 0x09,0xF8,0x88,0x89,0x8A,0x72,0x02,0x01,0xC0,0x32,0x0B,0x0A,0x0A,0x09,0x38,0x00,
  132. 0x04,0x3F,0x04,0x04,0x3F,0x04,0x04,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,
  133. 0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x00,
  134. 0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x30,0x00,
  135. 0x00,0x18,0x20,0x20,0x20,0x11,0x0E,0x00,0x00,0x07,0x04,0x24,0x24,0x3F,0x24,0x00,
  136. 0x00,0x19,0x21,0x20,0x20,0x11,0x0E,0x00,0x00,0x0F,0x11,0x20,0x20,0x11,0x0E,0x00,
  137. 0x00,0x19,0x24,0x22,0x22,0x22,0x3F,0x20,0x00,0x3F,0x11,0x20,0x20,0x11,0x0E,0x00,
  138. 0x00,0x0E,0x11,0x20,0x20,0x20,0x11,0x00,0x20,0x3C,0x23,0x02,0x02,0x27,0x38,0x20,
  139. 0x20,0x3F,0x20,0x20,0x20,0x11,0x0E,0x00,0x07,0x18,0x20,0x20,0x20,0x10,0x08,0x00,
  140. 0x10,0x90,0xFE,0x10,0x10,0x90,0xFE,0x10,0x00,0x00,0x00,0x04,0x04,0xFE,0x00,0x00,
  141. 0x00,0x00,0x00,0x00,0x00,0xC0,0x30,0x08,0x04,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,
  142. 0x00,0x60,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x04,0x04,0xFE,0x00,0x00,0x00,0x00,
  143. 0x00,0x00,0x1C,0x02,0x02,0x02,0x02,0xC2,0x3C,0x00,0x00,0x00,0x1C,0x02,0x42,0x42,
  144. 0x62,0x9C,0x00,0x00,0x00,0x00,0x80,0x40,0x40,0x40,0x40,0x40,0x80,0x00,0x00,0x00,
  145. 0x02,0xFE,0x80,0x40,0x40,0x40,0x80,0x00,0x00,0x00,0x00,0x80,0x40,0x40,0x40,0x80,
  146. 0x00,0x00,0x00,0x00,0x00,0x80,0x78,0x06,0x78,0x80,0x00,0x00,0x00,0x00,0x02,0xFE,
  147. 0x42,0x42,0x42,0x62,0x9C,0x00,0x00,0x00,0xF0,0x08,0x04,0x02,0x02,0x02,0x04,0x0E,
  148. 0x04,0x3F,0x04,0x04,0x04,0x3F,0x04,0x04,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,
  149. 0x00,0x00,0x00,0x00,0x03,0x02,0x02,0x22,0x22,0x3F,0x22,0x22,0x00,0x00,0x00,0x00,
  150. 0x00,0x30,0x30,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x20,0x3F,0x20,0x20,0x00,0x00,
  151. 0x00,0x00,0x30,0x28,0x24,0x22,0x21,0x20,0x38,0x00,0x00,0x00,0x1C,0x20,0x20,0x20,
  152. 0x20,0x10,0x0F,0x00,0x00,0x00,0x19,0x24,0x24,0x22,0x22,0x22,0x3F,0x20,0x30,0x00,
  153. 0x00,0x3F,0x10,0x20,0x20,0x20,0x10,0x0F,0x00,0x00,0x0F,0x10,0x20,0x20,0x20,0x11,
  154. 0x08,0x00,0x00,0x20,0x38,0x27,0x02,0x02,0x02,0x27,0x38,0x20,0x00,0x00,0x20,0x3F,
  155. 0x20,0x20,0x20,0x20,0x10,0x0F,0x00,0x00,0x07,0x18,0x20,0x20,0x20,0x20,0x10,0x0C,
  156. };

  157. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

  158. void         delay_ms(Uint t)
  159. {
  160.         Uchar i,j;
  161.         while(--t)
  162.         {
  163.         i=50;       
  164.         j=100;

  165.                 while(--j)
  166.                         while(--i);
  167.         }
  168. }
  169. void uDelay(Uchar l)
  170. {
  171.         while(l--);
  172. }


  173. void Delay(Uchar n)
  174. {
  175. Uchar i,j,k;

  176.         for(k=0;k<n;k++)
  177.         {
  178.                 for(i=0;i<131;i++)
  179.                 {
  180.                         for(j=0;j<15;j++)
  181.                         {
  182.                                 uDelay(203);       
  183.                         }
  184.                 }
  185.         }
  186. }


  187. //****************************************************************************
  188. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  189. //  Read/Write Sequence
  190. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  191. void I2C_3(Uchar mcmd)
  192. {
  193. Uchar length = 8;                        // Send Command

  194.         while(length--)
  195.         {
  196.                 if(mcmd & 0x80)
  197.                 {
  198.                         SDA3=1;
  199.                 }
  200.                 else
  201.                 {
  202.                         SDA3=0;
  203.                 }
  204. //                uDelay(3);
  205.                 SCL3=1;
  206. //                uDelay(3);
  207.                 SCL3=0;
  208. //                uDelay(3);
  209.                 mcmd = mcmd << 1;
  210.         }
  211. }


  212. void I2C_Ack3()
  213. {
  214.         SDA3=1;
  215. //        uDelay(3);
  216.         SCL3=1;
  217. //        uDelay(3);
  218.         SCL3=0;
  219. //        uDelay(3);
  220. }


  221. void I2C_NAck3()
  222. {
  223.         SDA3=0;
  224. //        uDelay(3);
  225.         SCL3=1;
  226. //        uDelay(3);
  227.         SCL3=0;
  228. //        uDelay(3);
  229. }


  230. void I2C_Start3()
  231. {
  232.         SDA3=0;
  233. //        uDelay(3);
  234.         SCL3=1;
  235. //        uDelay(3);
  236.         SCL3=0;
  237. //        uDelay(3);
  238.         I2C_3(0x78);
  239.         I2C_Ack3();
  240. }


  241. void I2C_Stop3()
  242. {
  243.         SCL3=1;
  244. //        uDelay(5);
  245.         SDA3=0;
  246. //        uDelay(5);
  247.         SDA3=1;
  248. //        uDelay(5);
  249. }


  250. void Write_Command3(Uchar Data)
  251. {
  252.         I2C_Start3();
  253.         I2C_3(0x00);
  254.         I2C_Ack3();
  255.         I2C_3(Data);
  256.         I2C_Ack3();
  257.         I2C_Stop3();
  258. }


  259. void Write_Data3(Uchar Data)
  260. {
  261.         I2C_Start3();
  262.         I2C_3(0x40);
  263.         I2C_Ack3();
  264.         I2C_3(Data);
  265.         I2C_Ack3();
  266.         I2C_Stop3();
  267. }
  268. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

  269. void        LCD_Init3(void)
  270. {
  271. //RES3=0;
  272. //uDelay(2);
  273. //RES3=1;
  274. //internal setting


  275. Write_Command3(0xae);        //--turn off oled panel

  276. Write_Command3(0x00);        //--set low column address
  277. Write_Command3(0x10);        //--set high column address

  278. Write_Command3(0x40);        //--set start line address

  279. Write_Command3(0xb0);        //--set page address

  280. Write_Command3(0x81);        //--set contrast control register
  281. Write_Command3(0xff);

  282. Write_Command3(0xa1);        //--set segment re-map 127 to 0   a0:0 to seg127
  283. Write_Command3(0xa6);        //--set normal display

  284. Write_Command3(0xc8);        //--set com(N-1)to com0  c0:com0 to com(N-1)

  285. Write_Command3(0xa8);        //--set multiples ratio(1to64)
  286. Write_Command3(0x3f);        //--1/64 duty

  287. Write_Command3(0xd3);        //--set display offset
  288. Write_Command3(0x00);        //--not offset

  289. Write_Command3(0xd5);        //--set display clock divide ratio/oscillator frequency
  290. Write_Command3(0x80);        //--set divide ratio

  291. Write_Command3(0xd9);        //--set pre-charge period
  292. Write_Command3(0xf1);

  293. Write_Command3(0xda);        //--set com pins hardware configuration
  294. Write_Command3(0x12);

  295. Write_Command3(0xdb);        //--set vcomh
  296. Write_Command3(0x40);

  297. Write_Command3(0x8d);        //--set chare pump enable/disable
  298. Write_Command3(0x14);        //--set(0x10) disable
  299. //Write_Command3(0x10);        //--set(0x10) disable
  300. Write_Command3(0xaf);        //--turn on oled panel
  301. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=void         LCD_Init(void)
  302. }


  303. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  304. void pic13(void)
  305. {
  306.         Uchar i,j;
  307.         Uint k;
  308.         k=0;
  309.         for(j=0;j<8;j++)
  310.         {
  311.                 Write_Command3(0x22);//--set page1
  312.                 Write_Command3(j);//--set start page
  313.                 Write_Command3(0x07);//--set end page

  314.                 for(i=0;i<128;i++)                                                  //显示单色数据到LCD
  315.                 {
  316.                         Write_Data3(color13[k]);
  317.                         k=k+1;
  318.                
  319.                 }
  320.         }
  321. }


  322. void pic14(void)
  323. {
  324.         Uchar i,j;
  325.         Uint k;
  326.         k=0;
  327.         for(j=0;j<8;j++)
  328.         {
  329.                 Write_Command3(0x22);//--set page1
  330.                 Write_Command3(j);//--set start page
  331.                 Write_Command3(0x07);//--set end page

  332.                 for(i=0;i<128;i++)                                                  //显示单色数据到LCD
  333.                 {
  334.                         Write_Data3(color14[k]);
  335.                         k=k+1;
  336.                
  337.                 }
  338.         }
  339. }
  340.                        
  341. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

  342. //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  343. void main()
  344. {

  345.         LCD_Init3();

  346.         while(1)

  347.         {   
  348.                 pic13();
  349.                 delay_ms(10);
  350.                 pic14();
  351.                 delay_ms(10);

  352.         }
  353. }
复制代码




回复

使用道具 举报

ID:685478 发表于 2020-1-27 10:26 | 显示全部楼层
你好,我复制了你的代码编译没有错误噢,只有WARNING L16: UNCALLED SEGMENT, IGNORED FOR OVERLAY PROCESS,,你上面的systax error我碰到的时候,都是中英输入法混了,你的=可能用了中文
回复

使用道具 举报

ID:235200 发表于 2020-1-27 16:46 | 显示全部楼层
图片未显示,看不到错误提示信息,点击错误信息可以去解决问题
回复

使用道具 举报

ID:342822 发表于 2020-1-27 18:04 | 显示全部楼层
屏幕截图(10).png

仿真正常~~~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表