我想用
STM32f103c8t6點亮ili9325液晶 程序如下
但是畫面全白 並沒有變成紅 {MOD}
想請教各位大大該如何修改? 謝謝
另外算了一下 320*240*2 = 150k
stm32f103c8t6的flash只有64k
所以就算想存一張圖片開機顯示也沒辨法
不知我這樣想對嗎? 謝謝
- /*
- PB8--------------------RS
- PB9--------------------RW
- PB10-------------------RD
- PB11-------------------CS
- PB12-------------------RST
- DB7 DB6 DB5 DB4 DB3 DB2 DB1 DB0
- PB12 PB13 PB14 PB5 PB6 PB7 PB1 PB0
- */
- #define White 0xFFFF
- #define Black 0x0000
- #define Blue 0x001F
- #define Red 0xF800
- #define Green 0x07E0
- #define Yellow 0xFFE0
- #define RSL GPIO_ResetBits(GPIOB,GPIO_Pin_10);
- #define RSH GPIO_SetBits(GPIOB,GPIO_Pin_10);
- #define RWL GPIO_ResetBits(GPIOB,GPIO_Pin_9);
- #define RWH GPIO_SetBits(GPIOB,GPIO_Pin_9);
- #define RDL GPIO_ResetBits(GPIOB,GPIO_Pin_8);
- #define RDH GPIO_SetBits(GPIOB,GPIO_Pin_8);
- #define CSL GPIO_ResetBits(GPIOB,GPIO_Pin_11);
- #define CSH GPIO_SetBits(GPIOB,GPIO_Pin_11);
- #define WINDOW_XADDR_START 0x0050 // Horizontal Start Address Set
- #define WINDOW_XADDR_END 0x0051 // Horizontal End Address Set
- #define WINDOW_YADDR_START 0x0052 // Vertical Start Address Set
- #define WINDOW_YADDR_END 0x0053 // Vertical End Address Set
- #define GRAM_XADDR 0x0020 // GRAM Horizontal Address Set
- #define GRAM_YADDR 0x0021 // GRAM Vertical Address Set
- #define GRAMWR 0x0022 // memory write
- u16 pin[8];
- void TFT_RCC_Config(void)
- {
- RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB | RCC_APB2Periph_AFIO, ENABLE);
- }
- void TFT_GPIO_Config(void)
- {
- GPIO_InitTypeDef GPIO_InitStructure;
- GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
- GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
- GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
- GPIO_Init(GPIOA,&GPIO_InitStructure);
- pin[0] = GPIO_Pin_0;
- pin[1] = GPIO_Pin_1;
- pin[2] = GPIO_Pin_7;
- pin[3] = GPIO_Pin_6;
- pin[4] = GPIO_Pin_5;
- pin[5] = GPIO_Pin_14;
- pin[6] = GPIO_Pin_13;
- pin[7] = GPIO_Pin_12;
- }
- void GPIO_WriteX(u8 t)
- {
- u8 i;
- for(i=0;i<8;i++)
- {
- GPIO_WriteBit(GPIOB, pin[i], (BitAction)((t>>i)&0x01) );
- }
- }
- void delay_ms_tft(u16 nms) {
- u32 temp;
- SysTick->LOAD = 72000*nms;
- SysTick->VAL=0X00;
- SysTick->CTRL=0X01;
- do{
- temp=SysTick->CTRL;
- }while((temp&0x01)&&(!(temp&(1<<16))));
- SysTick->CTRL=0x00;
- SysTick->VAL =0X00;
- }
- void delay_13ns(u8 t)
- {
- u8 j = 9;
- while(t--)
- {
- while (j--);
- }
- }
- //============================================================
- void Write_Cmd(u16 u)
- {
- u8 DH = u >> 8;
- u8 DL = u;
- RSL;
- delay_13ns(30);
- CSL;
- GPIO_WriteX(DH);
- RWL;
- RWH;
- delay_13ns(30);
- GPIO_WriteX(DL);
- RWL;
- RWH;
- delay_13ns(30);
- CSH;
- }
- void Write_Data(u16 u)
- {
- u8 DH = u >> 8;
- u8 DL = u;
- RSH;
- delay_13ns(30);
- CSL;
- GPIO_WriteX(DH);
- RWL;
- RWH;
- delay_13ns(30);
- GPIO_WriteX(DL);
- RWL;
- RWH;
- delay_13ns(30);
- CSH;
- }
- void Write_Cmd_Data (u16 cmd, u16 data)
- {
- Write_Cmd(cmd);
- Write_Data(data);
- }
- static void LCD_SetPos(u16 x0, u16 x1, u16 y0, u16 y1)
- {
- Write_Cmd_Data(WINDOW_XADDR_START, x0);
- Write_Cmd_Data(WINDOW_XADDR_END, x1);
- Write_Cmd_Data(WINDOW_YADDR_START, y0);
- Write_Cmd_Data(WINDOW_YADDR_END, y1);
- Write_Cmd_Data(GRAM_XADDR, x0);
- Write_Cmd_Data(GRAM_YADDR, y0);
- Write_Cmd(GRAMWR);
- }
- void CLR_Screen(u16 bColor)
- {
- u16 i,j;
- LCD_SetPos(0, 240, 0, 320); //320x240
- for (i=0;i<320;i++)
- {
- for (j=0;j<240;j++) Write_Data(bColor);
- }
- }
- void ILI9325_Initial(void)
- {
- CSL;
- delay_ms_tft(5);
- RSL;
- delay_ms_tft(5);
- RSH;
- delay_ms_tft(50);
- Write_Cmd_Data(0x0001,0x0100);
- Write_Cmd_Data(0x0002,0x0700);
- Write_Cmd_Data(0x0003,0x1030);
- Write_Cmd_Data(0x0004,0x0000);
- Write_Cmd_Data(0x0008,0x0207);
- Write_Cmd_Data(0x0009,0x0000);
- Write_Cmd_Data(0x000A,0x0000);
- Write_Cmd_Data(0x000C,0x0000);
- Write_Cmd_Data(0x000D,0x0000);
- Write_Cmd_Data(0x000F,0x0000);
- //power on sequence VGHVGL //-
- Write_Cmd_Data(0x0010,0x0000);
- Write_Cmd_Data(0x0011,0x0007);
- Write_Cmd_Data(0x0012,0x0000);
- Write_Cmd_Data(0x0013,0x0000);
- //vgh
- Write_Cmd_Data(0x0010,0x1290);
- Write_Cmd_Data(0x0011,0x0227);
- //vregiout
- Write_Cmd_Data(0x0012,0x001d); //0x001b
- //vom amplitude
- Write_Cmd_Data(0x0013,0x1500);
- //vom H
- Write_Cmd_Data(0x0029,0x0018);
- Write_Cmd_Data(0x002B,0x000D);
- //gamma //-
- Write_Cmd_Data(0x0030,0x0004);
- Write_Cmd_Data(0x0031,0x0307);
- Write_Cmd_Data(0x0032,0x0002); //0006
- Write_Cmd_Data(0x0035,0x0206);
- Write_Cmd_Data(0x0036,0x0408);
- Write_Cmd_Data(0x0037,0x0507);
- Write_Cmd_Data(0x0038,0x0204); //0200
- Write_Cmd_Data(0x0039,0x0707);
- Write_Cmd_Data(0x003C,0x0405); //0504
- Write_Cmd_Data(0x003D,0x0F02);
- //ram
- Write_Cmd_Data(0x0050,0x0000);
- Write_Cmd_Data(0x0051,0x00EF);
- Write_Cmd_Data(0x0052,0x0000);
- Write_Cmd_Data(0x0053,0x013F);
- Write_Cmd_Data(0x0060,0xA700);
- Write_Cmd_Data(0x0061,0x0001);
- Write_Cmd_Data(0x006A,0x0000);
- Write_Cmd_Data(0x0080,0x0000); //-
- Write_Cmd_Data(0x0081,0x0000); //-
- Write_Cmd_Data(0x0082,0x0000); //-
- Write_Cmd_Data(0x0083,0x0000); //-
- Write_Cmd_Data(0x0084,0x0000); //-
- Write_Cmd_Data(0x0085,0x0000); //-
- Write_Cmd_Data(0x0090,0x0010);
- Write_Cmd_Data(0x0092,0x0600);
- Write_Cmd_Data(0x0093,0x0003); //#
- Write_Cmd_Data(0x0095,0x0110);
- Write_Cmd_Data(0x0097,0x0000); //-
- Write_Cmd_Data(0x0098,0x0000); //-
- Write_Cmd_Data(0x0007,0x0133);
- delay_ms_tft(5);
- }
- //==============================================================
- void tft_init()
- {
- TFT_RCC_Config();
- TFT_GPIO_Config();
- ILI9325_Initial();
- CLR_Screen(Red);
- }
复制代码
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
你好 我不太了解你的意思
因為我只能透過jlink寫程序到mcu
再由mcu寫命令和資料到lcd
就算ili9325有顯存 我要如何一開始就把圖形存在裡面?
謝謝
你好 感謝解答
一周热门 更多>