1024手机基地看电影,午夜福利视频导航,国产精品福利在线一区,亚洲欧美日韩另类成人,在线观看午夜日本理论片,成年超爽免费网站,国产精品成人免费,精品动作一级毛片,成人免费观看网站,97精品伊人久久大香蕉

 找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開始

搜索
查看: 3459|回復(fù): 11
打印 上一主題 下一主題
收起左側(cè)

剛剛接觸stm32,有沒有大佬幫我看一下程序 LCD1602不顯示

[復(fù)制鏈接]
回帖獎(jiǎng)勵(lì) 9 黑幣 回復(fù)本帖可獲得 3 黑幣獎(jiǎng)勵(lì)! 每人限 1 次(中獎(jiǎng)概率 60%)
跳轉(zhuǎn)到指定樓層
樓主
這個(gè)程序的LCD1602引腳D0-D7是接到PB8-PB15嗎?   RS  PB5,     RW  PB4 ,      E  PB3這樣接對(duì)嗎
我這樣接的為什么不顯示

  1. #include "public.h"
  2. #define DATA (GPIO_Pin_8|GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12|GPIO_Pin_13|GPIO_Pin_14|GPIO_Pin_15)
  3. #define rs (GPIO_Pin_5)
  4. #define rw (GPIO_Pin_4)
  5. #define e (GPIO_Pin_3)
  6. u8 num[]="0123456789";
  7. u8 a[]=" welcome to PZ  ";
  8. u8 b[]=" Beautiful Girl ";
  9. void GPIOINIT()   //¶Ë¿Ú³õʼ»¯
  10. {
  11. GPIO_InitTypeDef GPIO_InitStructure;
  12. GPIO_InitStructure.GPIO_Pin=DATA|rs|rw|e;
  13. GPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;
  14. GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
  15. GPIO_Init(GPIOB,&GPIO_InitStructure);
  16. // GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable,ENABLE);//°Ñµ÷ÊÔÉèÖÃÆÕͨIO¿Ú
  17. }
  18. void RCCINIT() //ϵͳ³õʼ»¯
  19. {
  20. SystemInit();
  21. RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE);
  22.     //RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE);
  23. //Èç¹û²»¼ÓÕâÌõÓï¾ä³ÌÐòÏÔʾ¾Í»á³ö´í£¬¼´Ã»Óдò¿ª¶Ë¿Ú¸´Óù¦ÄܵÄʱÖÓÅäÖÃ
  24. }
  25. u8 readbusy() //æÐźżì²â
  26. {  
  27. u8 f;
  28. GPIO_ResetBits(GPIOB,rs);  
  29. GPIO_SetBits(GPIOB,rw);
  30. GPIO_SetBits(GPIOB,e);
  31. f=((GPIO_ReadInputData(GPIOB)&0X8000));
  32. delayms(10);
  33. GPIO_ResetBits(GPIOB,e);
  34. return f;  
  35. }
  36. void lcdwrc(u8 c)   //д°ËλÊý¾Ý
  37. {
  38. while(readbusy());
  39. GPIO_ResetBits(GPIOB,rs);  
  40. GPIO_ResetBits(GPIOB,rw);
  41. GPIO_ResetBits(GPIOB,e);
  42. delayms(1);
  43. GPIOB->BSRR = c<<8 & 0xf000;  //½«Êý¾ÝË͵½P0¿Ú
  44.     GPIOB->BRR = ((~c)<<8) & 0xf000;
  45. delayms(1);
  46. GPIO_SetBits(GPIOB,e);
  47. delayms(1);
  48. GPIO_ResetBits(GPIOB,e);
  49. delayms(1);
  50. }
  51. void lcdwrc4bit(long c)    //д8λÊý¾Ý,ͨ¹ý4¸öÒý½Å
  52. {
  53. while(readbusy());
  54. GPIO_ResetBits(GPIOB,rs);  
  55. GPIO_ResetBits(GPIOB,rw);
  56. GPIO_ResetBits(GPIOB,e);
  57. delayms(1);
  58. GPIOB->BSRR = c<<8 & 0xf000;  //½«Êý¾ÝË͵½P0¿Ú
  59.     GPIOB->BRR = ((~c)<<8) & 0xf000;
  60. delayms(1);
  61. GPIO_SetBits(GPIOB,e);
  62. delayms(1);
  63. GPIO_ResetBits(GPIOB,e);
  64. delayms(1);
  65. GPIOB->BSRR = c<<12 & 0xf000;  //½«Êý¾ÝË͵½P0¿Ú
  66.     GPIOB->BRR = ((~c)<<12) & 0xf000;
  67. delayms(1);
  68. GPIO_SetBits(GPIOB,e);
  69. delayms(1);
  70. GPIO_ResetBits(GPIOB,e);
  71. delayms(1);
  72. }
  73. void lcdwrd(long dat)   //¶Á°ËλÊý¾Ýͨ¹ý4¸öÒý½Å
  74. {
  75. while(readbusy());  
  76. GPIO_SetBits(GPIOB,rs);  
  77. GPIO_ResetBits(GPIOB,rw);
  78. GPIO_ResetBits(GPIOB,e);
  79. delayms(1);
  80. GPIOB->BSRR = dat<<8 & 0xf000;  //½«Êý¾ÝË͵½P0¿Ú
  81.     GPIOB->BRR = ((~dat)<<8) & 0xf000;
  82. delayms(1);
  83. GPIO_SetBits(GPIOB,e);
  84. delayms(1);
  85. GPIO_ResetBits(GPIOB,e);
  86. delayms(1);
  87. GPIOB->BSRR = dat<<12 & 0xf000;  //½«Êý¾ÝË͵½P0¿Ú
  88.     GPIOB->BRR = ((~dat)<<12) & 0xf000;
  89. delayms(1);
  90. GPIO_SetBits(GPIOB,e);
  91. delayms(1);
  92. GPIO_ResetBits(GPIOB,e);
  93. delayms(1);
  94. GPIO_ResetBits(GPIOB,rs);
  95. }
  96. void lcdinit()      //LCD³õʼ»¯
  97. {
  98. delayms(15);
  99. lcdwrc4bit(0x32);
  100. delayms(5);
  101. lcdwrc4bit(0x28);
  102. delayms(5);
  103. lcdwrc4bit(0x08);
  104. delayms(5);
  105. lcdwrc4bit(0x01);
  106. delayms(5);
  107. lcdwrc4bit(0x06);
  108. delayms(5);
  109. lcdwrc4bit(0x0c);
  110. delayms(5);
  111. }
  112. void display()    //ÏÔʾ
  113. {
  114. u8 i;
  115. lcdwrc4bit(0x00+0x80);
  116. for(i=0;i<16;i++)
  117. {
  118.   lcdwrd(a[i]);
  119. }
  120. lcdwrc4bit(0x40+0x80);
  121. for(i=0;i<16;i++)
  122. {
  123.   lcdwrd(b[i]);
  124. }
  125. }
  126. int main()
  127. {

  128. RCCINIT();   //  ÏµÍ³Ê±ÖÓ³õʼ»¯
  129. GPIOINIT();   //  ¶Ë¿Ú³õʼ»¯
  130. lcdinit(); //   Òº¾§ÏÔʾ³õʼ»¯
  131. while(1)
  132. {
  133.   display();   
  134. }
  135. }
復(fù)制代碼
分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

沙發(fā)
ID:295783 發(fā)表于 2018-4-21 15:01 | 只看該作者
有人看見嗎
回復(fù)

使用道具 舉報(bào)

板凳
ID:295783 發(fā)表于 2018-4-21 15:03 | 只看該作者
頂一下
回復(fù)

使用道具 舉報(bào)

地板
ID:150276 發(fā)表于 2018-4-22 17:27 | 只看該作者
LCD1602要5v供電,stm32是3.3v.你確定電平轉(zhuǎn)換正確嗎?
回復(fù)

使用道具 舉報(bào)

5#
ID:295783 發(fā)表于 2018-4-23 08:25 | 只看該作者
51在路上 發(fā)表于 2018-4-22 17:27
LCD1602要5v供電,stm32是3.3v.你確定電平轉(zhuǎn)換正確嗎?

32我用的是上面帶的USB電源,1602用的是5v
回復(fù)

使用道具 舉報(bào)

6#
ID:295783 發(fā)表于 2018-4-23 08:25 | 只看該作者
51在路上 發(fā)表于 2018-4-22 17:27
LCD1602要5v供電,stm32是3.3v.你確定電平轉(zhuǎn)換正確嗎?

我上面那樣接線對(duì)嗎
回復(fù)

使用道具 舉報(bào)

7#
ID:314258 發(fā)表于 2018-4-23 10:22 | 只看該作者
GPIOB->BSRR = c<<8 & 0xf000;
===>GPIOB->BSRR = c<<8 & 0xff00;
高8位
回復(fù)

使用道具 舉報(bào)

8#
ID:314301 發(fā)表于 2018-4-23 10:59 | 只看該作者
查一下1602的顯示方式,找好每一個(gè)點(diǎn)的顯示再進(jìn)行傳輸
回復(fù)

使用道具 舉報(bào)

9#
ID:295783 發(fā)表于 2018-4-23 12:55 | 只看該作者
PC7275 發(fā)表于 2018-4-23 10:59
查一下1602的顯示方式,找好每一個(gè)點(diǎn)的顯示再進(jìn)行傳輸

你覺得我連這個(gè)都不會(huì)嗎??? 老鐵!!!
回復(fù)

使用道具 舉報(bào)

10#
ID:699194 發(fā)表于 2020-3-29 21:23 | 只看該作者
程序新手 發(fā)表于 2018-4-23 08:25
32我用的是上面帶的USB電源,1602用的是5v

你這樣接電源,都沒有共GND給它,肯定不行的啊
回復(fù)

使用道具 舉報(bào)

11#
ID:592807 發(fā)表于 2020-3-30 08:40 | 只看該作者
初始化包括io口初始化和指令初始化,你有沒有使用指令對(duì)LCD初始化

(C.png (135.94 KB, 下載次數(shù): 27)

uc1617s指令

uc1617s指令
回復(fù)

使用道具 舉報(bào)

12#
ID:707815 發(fā)表于 2020-3-31 10:42 | 只看該作者
泥都知道打點(diǎn)了,那就應(yīng)該知道取模呀,我沒有看到你取得模,打點(diǎn)函數(shù),根據(jù)字模打點(diǎn),而且,打點(diǎn)的字模大小跟取模大小要一致,完成后,在進(jìn)行打單個(gè)字符,再根據(jù)打單個(gè)字符,打印字符串,得一步一步的來,你也可以把你那一句話直接取模,直接打點(diǎn)函數(shù)打印該字模
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

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

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表