完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
扫一扫,分享给好友
本人初学STM32,想尝试点亮2.4TFT,程序是从C51转换过来的,编译没有问题,但是下载STM32中始终是一片白板,弄了一整天也没点起色,实在是解决不了,所以想请哪位前辈帮我看看我的代码!指点指点,非常感谢!
//GPIO配置 void GPIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructure; //定义GPIO(结构体) RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|RCC_APB2Periph_GPIOC,ENABLE); 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); GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_SetBits(GPIOA,GPIO_Pin_All); GPIO_SetBits(GPIOB,GPIO_Pin_All); GPIO_SetBits(GPIOC,GPIO_Pin_All); } int main() { RCC_Configuration(); GPIO_Configuration(); delay_init(72); //72M晶振 ILI9325_Initial(); //初始化LCD while(1) { CLR_Screen(Red); //用背景色清屏 CLR_Screen(Green); //用背景色清屏 CLR_Screen(Blue); //用背景色清屏 } } #include"9325tp.h" /*---------------------------------------------------------------- 定义硬件端口 ----------------------------------------------------------------*/ #define RW PAout(12)//读写 #define RS PAout(11)//数据命令 #define RES PBout(7)//复位 #define CS PBout(8)//片选 unsigned char pic[]; /*---------------------------------------------------------------- 清屏函数 输入参数:bColor 清屏所使用的背景色 ----------------------------------------------------------------*/ void CLR_Screen(unsigned int bColor) { unsigned int i,j; LCD_SetPos(0,240,0,320);//320x240 for (i=0;i<320;i++) { for (j=0;j<240;j++) Write_Data_U16(bColor); } } /*---------------------------------------------------------------- 写命令、写数据 输入参数:x 需要输入的命令 16位 y 需要输入的数据 16位 ----------------------------------------------------------------*/ void Write_Cmd_Data (unsigned char x,unsigned int y) { unsigned char m,n; m=y>>8; n=y; Write_Cmd(0x00,x); Write_Data(m,n); } /*---------------------------------------------------------------- 写16位数据 ----------------------------------------------------------------*/ void Write_Data_U16(unsigned int y) { unsigned char m,n; m=y>>8; n=y; Write_Data(m,n); } /*---------------------------------------------------------------- 写命令 ----------------------------------------------------------------*/ void Write_Cmd(unsigned char DH,unsigned char DL) { u16 temp; CS=0; RS=0; temp=GPIOA->ODR&0xff00+(u16)DH;//不能改变高位的数据 GPIO_Write(GPIOA, temp); RW=0; RW=1; temp=GPIOA->ODR&0xff00+(u16)DL;//不能改变高位的数据 GPIO_Write(GPIOA, temp); RW=0; RW=1; CS=1; } /*---------------------------------------------------------------- 写数据 双8位 ----------------------------------------------------------------*/ void Write_Data(unsigned char DH,unsigned char DL) { u16 temp; CS=0; RS=1; temp=GPIOA->ODR&0xff00+(u16)DH;//不能改变高位的数据 GPIO_Write(GPIOA, temp); RW=0; RW=1; temp=GPIOA->ODR&0xff00+(u16)DL;//不能改变高位的数据 GPIO_Write(GPIOA, temp); RW=0; RW=1; CS=1; } /*---------------------------------------------------------------- 液晶初始化 ----------------------------------------------------------------*/ void ILI9325_Initial(void) { CS=1; delay_ms(5); RES=0; delay_ms(5); RES=1; delay_ms(5); delay_ms(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); //delay_ms(100); //vregiout Write_Cmd_Data(0x0012,0x001d); //0x001b //delay_ms(100); //vom amplitude Write_Cmd_Data(0x0013,0x1500); //delay_ms(100); //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); // Write_Cmd_Data(0x0022);// } /*---------------------------------------------------------------- 设置坐标 ----------------------------------------------------------------*/ static void LCD_SetPos(unsigned int x0,unsigned int x1,unsigned int y0,unsigned int 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 (0x00,0x22);//LCD_WriteCMD(GRAMWR); } |
|
相关推荐
14个回答
|
|
帮顶下,以前我也遇到过这个问题,但是好久了
|
|
|
|
我也很想解决这个问题。
|
|
|
|
|
|
|
|
和我一样的问题,你解决了吗
|
|
|
|
学习学习,感谢分享!
|
|
|
|
我的也是白板 一直不饿给现实 求解决啊
|
|
|
|
我也出现这样的问题,我用的是R61509V驱动芯片8位数据接口,在51上可以用,移植到STM32就是白板一块,程序编译也没问题,就是找不到问题出在哪儿?
https://bbs.elecfans.com/forum.p ... line%26typeid%3D806 |
|
|
|
请问你最终解决了吗?我也遇到这样的问题了
|
|
|
|
|
|
|
|
你看看是不是延时的问题,初始化里面的延时,主频不同,像这种初始化卡时间的外设,需要格外注意。
|
|
|
|
帮顶下,以前我也遇到过这个问题,但是好久了
|
|
|
|
这么多高人都解决不了啊,怎么改都是白板
|
|
|
|
你好,,请问你的问题解决了吗
|
|
|
|
谢谢分享,学习学习。。。
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
2183 浏览 1 评论
AD7686芯片不传输数据给STM32,但是手按住就会有数据。
2011 浏览 3 评论
4612 浏览 0 评论
如何解决MPU-9250与STM32通讯时,出现HAL_ERROR = 0x01U
2154 浏览 1 评论
hal库中i2c卡死在HAL_I2C_Master_Transmit
2687 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-12-25 14:06 , Processed in 1.134748 second(s), Total 69, Slave 63 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号