欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索

51單片機+LCD1602數據寫不了,小白求救

查看數: 1892 | 評論數: 5 | 收藏 1
關燈 | 提示:支持鍵盤翻頁<-左 右->
    組圖打開中,請稍候......
發布時間: 2022-1-22 21:33

正文摘要:

這是我的程序,可以寫命令,光標有動。就是寫不進去數據。 單片機源程序如下: #include <REGX52.H> #define uchar unsigned char #define uint unsigned int #define LCDDAT P0 sbit LCDRS=P2^6; sbit LCDRW= ...

回復

ID:149162 發表于 2022-1-23 13:14
void dalay(uchar x)
{
        uchar a,b;
        for(a=x;a<0;a--)
                for(b=110;b<0;b--);
}

中的“  for(a=x;a<0;a--)”明顯抄錯了
ID:1000104 發表于 2022-1-23 12:10
原來是我延時程序寫錯了,一樓二樓都給我說了.大家引以為戒
ID:1000104 發表于 2022-1-23 12:07
wulin 發表于 2022-1-23 11:04
樓主程序抄錯了,延時函數錯的離譜,導致LCD驅動代碼時序相去甚遠,LCD初始化失敗。

我說呢,就是這個問題.搞了半天.
ID:213173 發表于 2022-1-23 11:04
樓主程序抄錯了,延時函數錯的離譜,導致LCD驅動代碼時序相去甚遠,LCD初始化失敗。
  1. #include <REGX52.H>
  2. #define uchar unsigned char
  3. #define uint unsigned int
  4. #define LCDDAT P0
  5. sbit LCDRS=P2^6;
  6. sbit LCDRW=P2^5;
  7. sbit LCDEN=P2^7;

  8. void delay(uint x)
  9. {
  10.         uint a,b;
  11.         for(a=x;a>0;a--)
  12.                 for(b=110;b>0;b--);
  13. }
  14. void write_cmd(uchar cmd)
  15. {
  16.         LCDRS=0;
  17.         LCDRW=0;
  18.         LCDEN=0;
  19.         LCDDAT=cmd;
  20.         delay(1);
  21.         LCDEN=1;
  22.         delay(1);
  23.         LCDEN=0;
  24. }
  25. void write_data(uchar dat)
  26. {
  27.         LCDRS=1;
  28.         LCDRW=0;
  29.         LCDEN=0;
  30.         LCDDAT=dat;
  31.         delay(1);
  32.         LCDEN=1;
  33.         delay(1);
  34.         LCDEN=0;
  35. }
  36. void lcd_init()
  37. {
  38.         write_cmd(0x38);
  39.         write_cmd(0x0f);
  40.         write_cmd(0x06);
  41.         write_cmd(0x01);
  42. }

  43. void main()
  44. {
  45.         lcd_init();
  46.         write_cmd(0x80);
  47.         write_data('A');
  48.         write_data('B');
  49.         write_data('C');
  50.         write_data('D');
  51.         while(1);
  52. }
復制代碼
ID:625730 發表于 2022-1-22 23:28
你的初始化延時設置似乎不對。
可以參考鏈接里數據手冊設置。
http://m.raoushi.com/bbs/dpj-95896-1.html

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術交流QQ群281945664

Powered by 單片機教程網

快速回復 返回頂部 返回列表