stm32f103c8t6與ili9325液晶

2019-07-14 23:38发布

我想用STM32f103c8t6點亮ili9325液晶 程序如下
但是畫面全白 並沒有變成紅 {MOD}
想請教各位大大該如何修改? 謝謝

另外算了一下 320*240*2 = 150k
stm32f103c8t6的flash只有64k
所以就算想存一張圖片開機顯示也沒辨法
不知我這樣想對嗎? 謝謝

  1. /*
  2. PB8--------------------RS
  3. PB9--------------------RW
  4. PB10-------------------RD
  5. PB11-------------------CS
  6. PB12-------------------RST
  7. DB7    DB6    DB5    DB4    DB3    DB2    DB1    DB0
  8. PB12   PB13   PB14   PB5    PB6    PB7    PB1    PB0
  9. */

  10. #define White          0xFFFF
  11. #define Black          0x0000
  12. #define Blue           0x001F
  13. #define Red            0xF800
  14. #define Green          0x07E0
  15. #define Yellow         0xFFE0

  16. #define RSL GPIO_ResetBits(GPIOB,GPIO_Pin_10);
  17. #define RSH GPIO_SetBits(GPIOB,GPIO_Pin_10);
  18. #define RWL GPIO_ResetBits(GPIOB,GPIO_Pin_9);
  19. #define RWH GPIO_SetBits(GPIOB,GPIO_Pin_9);
  20. #define RDL GPIO_ResetBits(GPIOB,GPIO_Pin_8);
  21. #define RDH GPIO_SetBits(GPIOB,GPIO_Pin_8);
  22. #define CSL GPIO_ResetBits(GPIOB,GPIO_Pin_11);
  23. #define CSH GPIO_SetBits(GPIOB,GPIO_Pin_11);

  24. #define WINDOW_XADDR_START        0x0050        // Horizontal Start Address Set
  25. #define WINDOW_XADDR_END    0x0051        // Horizontal End Address Set
  26. #define WINDOW_YADDR_START        0x0052        // Vertical Start Address Set
  27. #define WINDOW_YADDR_END    0x0053        // Vertical End Address Set
  28. #define GRAM_XADDR                                        0x0020        // GRAM Horizontal Address Set
  29. #define GRAM_YADDR                                        0x0021        // GRAM Vertical Address Set
  30. #define GRAMWR                                                        0x0022        // memory write

  31. u16 pin[8];

  32. void TFT_RCC_Config(void)
  33. {
  34.         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE);
  35. }

  36. void TFT_GPIO_Config(void)
  37. {
  38.         GPIO_InitTypeDef GPIO_InitStructure;

  39.         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
  40.         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  41.         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;     
  42.         GPIO_Init(GPIOA,&GPIO_InitStructure);

  43.         pin[0] = GPIO_Pin_0;
  44.         pin[1] = GPIO_Pin_1;
  45.         pin[2] = GPIO_Pin_7;
  46.         pin[3] = GPIO_Pin_6;
  47.         pin[4] = GPIO_Pin_5;
  48.         pin[5] = GPIO_Pin_14;
  49.         pin[6] = GPIO_Pin_13;
  50.         pin[7] = GPIO_Pin_12;
  51. }

  52. void GPIO_WriteX(u8 t)
  53. {
  54.     u8 i;
  55.     for(i=0;i<8;i++)
  56.     {
  57.                         GPIO_WriteBit(GPIOB, pin[i], (BitAction)((t>>i)&0x01) );
  58.     }
  59. }

  60. void delay_ms_tft(u16 nms) {
  61.         u32 temp;
  62.         SysTick->LOAD = 72000*nms;
  63.         SysTick->VAL=0X00;
  64.         SysTick->CTRL=0X01;
  65.         do{
  66.                 temp=SysTick->CTRL;
  67.         }while((temp&0x01)&&(!(temp&(1<<16))));
  68.         SysTick->CTRL=0x00;
  69.   SysTick->VAL =0X00;
  70. }

  71. void delay_13ns(u8 t)
  72. {
  73.         u8 j = 9;
  74.         while(t--)
  75.         {
  76.                 while (j--);
  77.         }
  78. }  

  79. //============================================================

  80. void Write_Cmd(u16 u)
  81. {
  82.                 u8 DH = u >> 8;
  83.                 u8 DL = u;
  84.     RSL;
  85.     delay_13ns(30);
  86.     CSL;
  87.     GPIO_WriteX(DH);
  88.     RWL;
  89.     RWH;
  90.     delay_13ns(30);
  91.     GPIO_WriteX(DL);
  92.     RWL;
  93.     RWH;
  94.     delay_13ns(30);
  95.     CSH;
  96. }

  97. void Write_Data(u16 u)
  98. {
  99.                 u8 DH = u >> 8;
  100.                 u8 DL = u;
  101.     RSH;
  102.     delay_13ns(30);
  103.     CSL;
  104.     GPIO_WriteX(DH);
  105.     RWL;
  106.     RWH;
  107.     delay_13ns(30);
  108.     GPIO_WriteX(DL);
  109.     RWL;
  110.     RWH;
  111.     delay_13ns(30);
  112.     CSH;
  113. }

  114. void Write_Cmd_Data (u16 cmd, u16 data)
  115. {
  116.                 Write_Cmd(cmd);
  117.     Write_Data(data);
  118. }

  119. static void LCD_SetPos(u16 x0, u16 x1, u16 y0, u16 y1)
  120. {
  121.   Write_Cmd_Data(WINDOW_XADDR_START, x0);
  122.   Write_Cmd_Data(WINDOW_XADDR_END, x1);
  123.   Write_Cmd_Data(WINDOW_YADDR_START, y0);
  124.   Write_Cmd_Data(WINDOW_YADDR_END, y1);
  125.   Write_Cmd_Data(GRAM_XADDR, x0);
  126.   Write_Cmd_Data(GRAM_YADDR, y0);
  127.         Write_Cmd(GRAMWR);
  128. }

  129. void CLR_Screen(u16 bColor)
  130. {
  131.         u16 i,j;
  132.         LCD_SetPos(0, 240, 0, 320);        //320x240
  133.         for (i=0;i<320;i++)
  134.         {
  135.                 for (j=0;j<240;j++) Write_Data(bColor);
  136.         }
  137. }

  138. void ILI9325_Initial(void)
  139. {
  140. CSL;
  141. delay_ms_tft(5);
  142. RSL;
  143. delay_ms_tft(5);
  144. RSH;
  145. delay_ms_tft(50);
  146. Write_Cmd_Data(0x0001,0x0100);
  147. Write_Cmd_Data(0x0002,0x0700);
  148. Write_Cmd_Data(0x0003,0x1030);
  149. Write_Cmd_Data(0x0004,0x0000);
  150. Write_Cmd_Data(0x0008,0x0207);  
  151. Write_Cmd_Data(0x0009,0x0000);
  152. Write_Cmd_Data(0x000A,0x0000);
  153. Write_Cmd_Data(0x000C,0x0000);
  154. Write_Cmd_Data(0x000D,0x0000);
  155. Write_Cmd_Data(0x000F,0x0000);
  156. //power on sequence VGHVGL                //-
  157. Write_Cmd_Data(0x0010,0x0000);   
  158. Write_Cmd_Data(0x0011,0x0007);  
  159. Write_Cmd_Data(0x0012,0x0000);  
  160. Write_Cmd_Data(0x0013,0x0000);
  161. //vgh
  162. Write_Cmd_Data(0x0010,0x1290);   
  163. Write_Cmd_Data(0x0011,0x0227);
  164. //vregiout
  165. Write_Cmd_Data(0x0012,0x001d); //0x001b
  166. //vom amplitude
  167. Write_Cmd_Data(0x0013,0x1500);
  168. //vom H
  169. Write_Cmd_Data(0x0029,0x0018);
  170. Write_Cmd_Data(0x002B,0x000D);

  171. //gamma                //-
  172. Write_Cmd_Data(0x0030,0x0004);
  173. Write_Cmd_Data(0x0031,0x0307);
  174. Write_Cmd_Data(0x0032,0x0002);        //0006
  175. Write_Cmd_Data(0x0035,0x0206);
  176. Write_Cmd_Data(0x0036,0x0408);
  177. Write_Cmd_Data(0x0037,0x0507);
  178. Write_Cmd_Data(0x0038,0x0204);        //0200
  179. Write_Cmd_Data(0x0039,0x0707);
  180. Write_Cmd_Data(0x003C,0x0405);        //0504
  181. Write_Cmd_Data(0x003D,0x0F02);
  182. //ram
  183. Write_Cmd_Data(0x0050,0x0000);
  184. Write_Cmd_Data(0x0051,0x00EF);
  185. Write_Cmd_Data(0x0052,0x0000);
  186. Write_Cmd_Data(0x0053,0x013F);  
  187. Write_Cmd_Data(0x0060,0xA700);
  188. Write_Cmd_Data(0x0061,0x0001);
  189. Write_Cmd_Data(0x006A,0x0000);

  190. Write_Cmd_Data(0x0080,0x0000);        //-
  191. Write_Cmd_Data(0x0081,0x0000);        //-
  192. Write_Cmd_Data(0x0082,0x0000);        //-
  193. Write_Cmd_Data(0x0083,0x0000);        //-
  194. Write_Cmd_Data(0x0084,0x0000);        //-
  195. Write_Cmd_Data(0x0085,0x0000);        //-

  196. Write_Cmd_Data(0x0090,0x0010);
  197. Write_Cmd_Data(0x0092,0x0600);
  198. Write_Cmd_Data(0x0093,0x0003);         //#
  199. Write_Cmd_Data(0x0095,0x0110);
  200. Write_Cmd_Data(0x0097,0x0000);         //-
  201. Write_Cmd_Data(0x0098,0x0000);                //-
  202. Write_Cmd_Data(0x0007,0x0133);   

  203. delay_ms_tft(5);
  204. }

  205. //==============================================================

  206. void tft_init()
  207. {
  208.         TFT_RCC_Config();
  209.         TFT_GPIO_Config();
  210.   ILI9325_Initial();
  211. CLR_Screen(Red);
  212. }

复制代码


友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
该问题目前已经被作者或者管理员关闭, 无法添加新回复
4条回答
wlbill
1楼-- · 2019-07-15 07:51
ili9325自带显存 足够显示一副图片,不需要用stm32的flsah,你多虑了。
kagaya
2楼-- · 2019-07-15 09:18
wlbill 发表于 2014-6-3 10:46
ili9325自带显存 足够显示一副图片,不需要用stm32的flsah,你多虑了。

你好 我不太了解你的意思
因為我只能透過jlink寫程序到mcu
再由mcu寫命令和資料到lcd
就算ili9325有顯存 我要如何一開始就把圖形存在裡面?
謝謝
wlbill
3楼-- · 2019-07-15 13:37
 精彩回答 2  元偷偷看……
kagaya
4楼-- · 2019-07-15 14:26
wlbill 发表于 2014-6-5 10:59
我理解错了,如果是这样你确实需要一块片外的rom。ili9325显存是ram类型。

你好 感謝解答                                       

一周热门 更多>