完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
本人刚入门STM32不久。最近自己设计了一款stm32最小系统+SD卡+TFT触摸屏。在写3.2寸TFT驱动程序时,参数设置使用了原厂提供的初始化程序,可是屏幕变成背景灰色,有一道一道的纹线,使用原子的驱动程序也出现同样的情况。读取屏幕的ID,可以正确的读到9431。现在卡在这里,不知道怎么办。请各位大神指点迷津。
程序如下: ILI9341驱动程序: #include #include "delay.h" extern int REK; //ID号 void ILI9341_GPIO_config(void) //引脚配置 { GPIO_InitTypeDef GPIO_InitStructure; GPIO_PinRemapConfig(GPIO_Remap_SWJ_Disable , ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_AFIO, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_7|GPIO_Pin_6|GPIO_Pin_5|GPIO_Pin_4|GPIO_Pin_3; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_ResetBits(GPIOA,GPIO_Pin_All); } void LCD_WR_DATA(unsigned int val) //写数据 { LCD_RS_SET; LCD_RD_SET; LCD_CS_CLR; DATAOUT(val); LCD_WR_CLR; LCD_WR_SET; LCD_CS_SET; } void LCD_WR_REG(unsigned int reg) //写命令字 { LCD_RS_CLR;//дµØÖ· LCD_RD_SET; LCD_CS_CLR; DATAOUT(reg); LCD_WR_CLR; LCD_WR_SET; LCD_CS_SET; } u16 LCD_RD_DATA(void) //读数据 使用原子的程序 { u16 t; GPIOA->CRL=0X88888888; GPIOA->CRH=0X88888888; GPIOA->ODR=0X0000; LCD_RS_SET; LCD_CS_CLR; LCD_RD_CLR; t=DATAIN; LCD_RD_SET; LCD_CS_SET; GPIOA->CRL=0X33333333; GPIOA->CRH=0X33333333; GPIOA->ODR=0XFFFF; return t; } void LCD_Init(void) //ILI9341初始化 { ILI9341_GPIO_config(); LCD_RE_SET; delay_ms(100); LCD_RE_CLR; delay_ms(200); LCD_RE_SET; delay_ms(300); LCD_WR_REG(0xD3); LCD_RD_DATA(); //dummy read LCD_RD_DATA(); REK=LCD_RD_DATA(); REK<<=8; REK|=LCD_RD_DATA(); LCD_WR_REG(0xCF); LCD_WR_DATA(0x00); LCD_WR_DATA(0xC1); LCD_WR_DATA(0X30); LCD_WR_REG(0xED); LCD_WR_DATA(0x64); LCD_WR_DATA(0x03); LCD_WR_DATA(0X12); LCD_WR_DATA(0X81); LCD_WR_REG(0xE8); LCD_WR_DATA(0x85); LCD_WR_DATA(0x00); LCD_WR_DATA(0x79); LCD_WR_REG(0xCB); LCD_WR_DATA(0x39); LCD_WR_DATA(0x2C); LCD_WR_DATA(0x00); LCD_WR_DATA(0x34); LCD_WR_DATA(0x02); LCD_WR_REG(0xF7); LCD_WR_DATA(0x20); LCD_WR_REG(0xEA); LCD_WR_DATA(0x00); LCD_WR_DATA(0x00); LCD_WR_REG(0xC0); //Power control LCD_WR_DATA(0x1D); //VRH[5:0] LCD_WR_REG(0xC1); //Power control LCD_WR_DATA(0x12); //SAP[2:0];BT[3:0] LCD_WR_REG(0xC5); //VCM control LCD_WR_DATA(0x33); LCD_WR_DATA(0x3F); LCD_WR_REG(0xC7); //VCM control LCD_WR_DATA(0x92); LCD_WR_REG(0x3A); // Memory Access Control LCD_WR_DATA(0x55); LCD_WR_REG(0x36); // Memory Access Control LCD_WR_DATA(0x08); LCD_WR_REG(0xB1); LCD_WR_DATA(0x00); LCD_WR_DATA(0x12); LCD_WR_REG(0xB6); // Display Function Control LCD_WR_DATA(0x0A); LCD_WR_DATA(0xA2); LCD_WR_REG(0x44); LCD_WR_DATA(0x02); LCD_WR_REG(0xF2); // 3Gamma Function Disable LCD_WR_DATA(0x00); LCD_WR_REG(0x26); //Gamma curve selected LCD_WR_DATA(0x01); LCD_WR_REG(0xE0); //Set Gamma LCD_WR_DATA(0x0F); LCD_WR_DATA(0x22); LCD_WR_DATA(0x1C); LCD_WR_DATA(0x1B); LCD_WR_DATA(0x08); LCD_WR_DATA(0x0F); LCD_WR_DATA(0x48); LCD_WR_DATA(0xB8); LCD_WR_DATA(0x34); LCD_WR_DATA(0x05); LCD_WR_DATA(0x0C); LCD_WR_DATA(0x09); LCD_WR_DATA(0x0F); LCD_WR_DATA(0x07); LCD_WR_DATA(0x00); LCD_WR_REG(0XE1); //Set Gamma LCD_WR_DATA(0x00); LCD_WR_DATA(0x23); LCD_WR_DATA(0x24); LCD_WR_DATA(0x07); LCD_WR_DATA(0x10); LCD_WR_DATA(0x07); LCD_WR_DATA(0x38); LCD_WR_DATA(0x47); LCD_WR_DATA(0x4B); LCD_WR_DATA(0x0A); LCD_WR_DATA(0x13); LCD_WR_DATA(0x06); LCD_WR_DATA(0x30); LCD_WR_DATA(0x38); LCD_WR_DATA(0x0F); LCD_WR_REG(0x11); //Exit Sleep delay_ms(120); LCD_WR_REG(0x29); //Display on } void LCD_SetArea(unsigned int stx,unsigned int sty,unsigned int endx,unsigned int endy) //设置窗口 { LCD_WR_REG(0x2A); // LCD_WR_DATA((stx>>8)&0x00ff); // LCD_WR_DATA(stx&0x00ff); // LCD_WR_DATA((endx>>8)&0x00ff); // LCD_WR_DATA(endx&0x00ff); LCD_WR_DATA(0x00); LCD_WR_DATA(0x00); LCD_WR_DATA(0x01); LCD_WR_DATA(0x3f); // LCD_WR_DATAX(stx); // LCD_WR_DATAX(endx); LCD_WR_REG(0x2B); // LCD_WR_DATA((sty>>8)&0x00ff); // LCD_WR_DATA(sty&0x00ff); // LCD_WR_DATA((endy>>8)&0x00ff); // LCD_WR_DATA(endy&0x00ff); LCD_WR_DATA(0x00); LCD_WR_DATA(0x00); LCD_WR_DATA(0x00); LCD_WR_DATA(0xef); // LCD_WR_DATAX(sty); // LCD_WR_DATAX(endy); } void LCD_SetAreaXY(unsigned char x,unsigned int y) { LCD_SetArea(x,y,x,y); } void LcdWirteColorData(unsigned int color) //写颜色值至ILI9341 { LCD_RS_SET; LCD_RD_SET; LCD_CS_CLR; DATAOUT(color); LCD_WR_CLR; LCD_WR_SET; LCD_CS_SET; } void LCD_Clear(unsigned int color) //清屏操作 { unsigned int i,j; LCD_SetArea(0,0,239,319); LCD_WR_REG(0x2C); for(i = 0;i < 320;i++) { for(j = 0;j < 240;j++) { LcdWirteColorData(color); } } } 主函数: int REK = 0xffff; int main(void) { USART3_Config(9600); delay_init(); LCD_Init(); LCD_Clear(Yellow); while(1) { printf("ID is :%xn",REK); LCD_Clear(Yellow); } }
|
|
相关推荐
2个回答
|
|
感觉收获很多,感谢楼主的分享,给自己加加油;;;;;;;;;;;;;;
|
|
|
|
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
2272 浏览 1 评论
AD7686芯片不传输数据给STM32,但是手按住就会有数据。
2083 浏览 3 评论
4708 浏览 0 评论
如何解决MPU-9250与STM32通讯时,出现HAL_ERROR = 0x01U
2229 浏览 1 评论
hal库中i2c卡死在HAL_I2C_Master_Transmit
2773 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-27 13:52 , Processed in 1.043225 second(s), Total 76, Slave 57 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (威廉希尔官方网站 图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号