串行12864STM32程序

串行12864STM32程序

ID:40775197

大小:19.42 KB

页数:4页

时间:2019-08-07

串行12864STM32程序_第1页
串行12864STM32程序_第2页
串行12864STM32程序_第3页
串行12864STM32程序_第4页
资源描述:

《串行12864STM32程序》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库

1、串行12864&STM32程序文档说明:此程序是从串行12864LCD的51程序中改写过来的。另:此程序是基于STM32f103内核芯片开发的,使用的屏幕为JLX12864G-086串行LCD。/*********lcd12864.h**********//*********lcd12864.c**********/#include"lcd_12864.h"/*其中SDA、SCK、RS、CS、RST已在头文件中宏定义*//*LCD_GPIOInit*/voidGPIO_LCD(void){GPIO_InitTypeDe

2、fGPIO_InitStructure;GPIO_InitStructure.GPIO_Pin=SDA;//SDAGPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_Init(GPIO_SDA,&GPIO_InitStructure);GPIO_InitStructure.GPIO_Pin=SCK;//SCKGPIO_InitStructure.GPIO_Mode=GPIO_M

3、ode_Out_PP;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_Init(GPIO_SCK,&GPIO_InitStructure);GPIO_InitStructure.GPIO_Pin=RST;//RSTGPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_Init(GPIO_RST,&GPIO_InitStruc

4、ture);GPIO_InitStructure.GPIO_Pin=RS;//RSGPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_Init(GPIO_RS,&GPIO_InitStructure);GPIO_InitStructure.GPIO_Pin=CS;//CSGPIO_InitStructure.GPIO_Mode=GPIO_Mode_Out_PP;GPIO_Ini

5、tStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_Init(GPIO_CS,&GPIO_InitStructure);}/*writecommandtoLCD*/voidwrite_command(unsignedshortintcommand){unsignedshortinti;CS_L;//开启片选(低电平有效)RS_L;//开启寄存器地址for(i=0;i<8;i++){SCK_L;//拉高时钟线——同SPI原理差不多if(command&0x80) //传输指令{SDA_

6、H;}else{SDA_L;}SCK_H; //LCD读取指令command=command<<1;}CS_H;//关闭片选}/*writedatatoLCD*/voidwrite_data(unsignedshortintdata){unsignedshortinti;CS_L;RS_H;//开启数据地址for(i=0;i<8;i++){SCK_L;if(data&0x80){SDA_H;}else{SDA_L;}SCK_H;data=data<<1;}CS_H;}/*LCDInit*/voidlcd_Init(vo

7、id){GPIO_LCD();//LCD管脚配置初始化CS_L;//开启片选RST_L;//LCD复位(低电平)delay_ms(22);RST_H;delay_ms(5);write_command(0xe2);//软件复位delay_ms(2);write_command(0x2c);//内部升压delay_ms(2);write_command(0x2e);//电压调整电路delay_ms(2);write_command(0x2f);//电压跟随delay_ms(2);write_command(0x23);/

8、/粗调对比度write_command(0x81);//细调对比度(不改)write_command(0x28);//细调对比度write_command(0xa2);//write_command(0xc8);//write_command(0xa0);//write_command(0x40);//write_command(

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。