找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2961|回复: 6
收起左侧

求大神看一下单片机+LCD12232显示的字体为什么是镜像的

[复制链接]
ID:700110 发表于 2020-3-3 16:26 | 显示全部楼层 |阅读模式
TIM图片20200303161855.png TIM图片20200303162236.png
根据lab8000用proteus仿真的 刚刚接触这个LCD,可能连线不对,单片机代码如下
  1. #include<reg51.h>
  2. #define PD1 61

  3. unsigned char Column;
  4. unsigned char Page_;
  5. unsigned char Code_;
  6. unsigned char Command;
  7. unsigned char LCDData;

  8. xdata unsigned char CWADD1 _at_ 0x8000;
  9. xdata unsigned char DWADD1 _at_ 0x8001;
  10. xdata unsigned char CRADD1 _at_ 0x8002;
  11. xdata unsigned char DRADD1 _at_ 0x8003;

  12. xdata unsigned char CWADD2 _at_ 0x8004;
  13. xdata unsigned char DWADD2 _at_ 0x8005;
  14. xdata unsigned char CRADD2 _at_ 0x8006;
  15. xdata unsigned char DRADD2 _at_ 0x8007;

  16. code unsigned char EETAB[ ][8]={
  17.     {0x38,0x44,0x44,0x44,0x44,0x44,0x38,0x00},
  18.     {0x10,0x30,0x50,0x10,0x10,0x10,0x7c,0x00},
  19.     {0x38,0x44,0x04,0x08,0x10,0x20,0x7c,0x00},
  20.     {0x78,0x84,0x04,0x38,0x04,0x84,0x78,0x00}
  21. };

  22. code unsigned char CCTAB[][32] ={
  23.     {0x00,0x04,0xe4,0x24,0x24,0x64,0xb4,0x2f,
  24.     0x24,0xa4,0x64,0x24,0x24,0xe6,0x04,0x00,
  25.     0x00,0x00,0x7f,0x04,0x05,0x05,0x05,0x7f,
  26.     0x05,0x05,0x05,0x25,0x44,0x3f,0x00,0x00},

  27.     {0x00,0x04,0xe4,0x24,0x24,0x64,0xb4,0x2f,
  28.     0x24,0xa4,0x64,0x24,0x24,0xe6,0x04,0x00,
  29.     0x00,0x00,0x7f,0x04,0x05,0x05,0x05,0x7f,
  30.     0x05,0x05,0x05,0x25,0x44,0x3f,0x00,0x00},

  31.     {0x00,0x04,0xe4,0x24,0x24,0x64,0xb4,0x2f,
  32.     0x24,0xa4,0x64,0x24,0x24,0xe6,0x04,0x00,
  33.     0x00,0x00,0x7f,0x04,0x05,0x05,0x05,0x7f,
  34.     0x05,0x05,0x05,0x25,0x44,0x3f,0x00,0x00},

  35.     {0x00,0x04,0xe4,0x24,0x24,0x64,0xb4,0x2f,
  36.     0x24,0xa4,0x64,0x24,0x24,0xe6,0x04,0x00,
  37.     0x00,0x00,0x7f,0x04,0x05,0x05,0x05,0x7f,
  38.     0x05,0x05,0x05,0x25,0x44,0x3f,0x00,0x00}
  39. };

  40. void WriteCommandE1(){
  41.     while(CRADD1 & 0x80);
  42.     CWADD1 = Command;
  43. }

  44. void WriteDataE1(){
  45.     while(CRADD1 & 0x80);
  46.     DWADD1 = LCDData;
  47. }

  48. void ReadDataE1(){
  49.     while(CRADD1 & 0x80);
  50.     LCDData = DRADD1;
  51. }

  52. void WriteCommandE2(){
  53.     while(CRADD2 & 0x80);
  54.     CWADD2 = Command;
  55. }

  56. void WriteDataE2(){
  57.     while(CRADD2 & 0x80);
  58.     DWADD2 = LCDData;
  59. }

  60. void ReadDataE2(){
  61.     while(CRADD2 & 0x80);
  62.     LCDData = DRADD2;
  63. }

  64. void Init(){
  65.     Command = 0xe2;

  66.     WriteCommandE1();
  67.     WriteCommandE2();

  68.     Command = 0xa4;
  69.     WriteCommandE1();
  70.     WriteCommandE2();

  71.     Command = 0xa9;
  72.     WriteCommandE1();
  73.     WriteCommandE2();

  74.     Command = 0xa0;
  75.     WriteCommandE1();
  76.     WriteCommandE2();

  77.     Command = 0xc0;
  78.     WriteCommandE1();
  79.     WriteCommandE2();

  80.     Command = 0xaf;
  81.     WriteCommandE1();
  82.     WriteCommandE2();

  83. }

  84. void Clear(){
  85.     unsigned char i, j;
  86.     i = 0;
  87.     do{
  88.         Command = (i + 0xb8);
  89.         WriteCommandE1();
  90.         WriteCommandE2();

  91.         Command = 0x00;
  92.         WriteCommandE1();
  93.         WriteCommandE2();
  94.         j = 0x50;
  95.         do{
  96.             LCDData = 0x00;
  97.             WriteDataE1();
  98.             WriteDataE2();
  99.         }while(--j!=0);
  100.     }while(++i!=4);
  101. }

  102. void Delay(){
  103.     unsigned char i, j;
  104.     i = 20;
  105.     j = 0;
  106.     do{
  107.         do{
  108.         }while(--j!=0);
  109.     }while(--i!=0);
  110. }

  111. void WriteCHN16x16(){
  112.     unsigned char i, j, k;
  113.     i = 0;
  114.     j = 0;
  115.     while(j<2){
  116.         Command = ((Page_ + j) & 0x03)|0xb8;
  117.         WriteCommandE1();
  118.         WriteCommandE2();
  119.         k = Column;
  120.         while(k < Column + 16){
  121.             if(k < PD1){
  122.                 Command = k;
  123.                 WriteCommandE1();
  124.                 LCDData = CCTAB[Code_][i];
  125.                 WriteDataE1();
  126.             }
  127.             else{
  128.                 Command = k-PD1;
  129.                 WriteCommandE2();
  130.                 LCDData = CCTAB[Code_][/i][i][i];
  131.                 WriteDataE2();
  132.             }
  133.             i++;
  134.             if(++k >= PD1*2) break;
  135.         }
  136.         j++;
  137.     }
  138. }

  139. void main(){
  140.     Init();
  141.     Clear();
  142.     Page_ = 0x02;
  143.     Column = 0x00;
  144.     Code_ = 0x00;
  145.     WriteCHN16x16();

  146.     while(1);
  147. }
复制代码


回复

使用道具 举报

ID:617449 发表于 2020-3-3 17:33 | 显示全部楼层
那就取模的时候先镜像一下,显示就是正的了
回复

使用道具 举报

ID:105364 发表于 2020-3-3 18:12 | 显示全部楼层
程序没错。很久以前做过,仿真就这样是镜像 的,同样程序放实物就正确的。
12232.jpg 91529822720e0cf3233037760a46f21fbf09aa7c.jpg

回复

使用道具 举报

ID:700110 发表于 2020-3-3 21:39 | 显示全部楼层
47okey 发表于 2020-3-3 18:12
程序没错。很久以前做过,仿真就这样是镜像 的,同样程序放实物就正确的。

大佬,那您能帮我看下我定义的应该是在第二行第一位的位置,为什么在中间呢
回复

使用道具 举报

ID:704664 发表于 2020-3-10 09:10 | 显示全部楼层
小哥,你是在做汉字滚动的设计吗
回复

使用道具 举报

ID:897458 发表于 2021-12-24 08:25 来自触屏版 | 显示全部楼层
不同厂家生产的屏方向不同
回复

使用道具 举报

ID:232791 发表于 2021-12-28 09:06 | 显示全部楼层
程序设置180°翻转
回复

使用道具 举报

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

本版积分规则

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

Powered by 单片机教程网

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