12864液晶屏(带字库)51单片机3线串口驱动程序

上传人:灯火****19 文档编号:122002540 上传时间:2020-02-29 格式:DOC 页数:11 大小:16.32KB
返回 下载 相关 举报
12864液晶屏(带字库)51单片机3线串口驱动程序_第1页
第1页 / 共11页
12864液晶屏(带字库)51单片机3线串口驱动程序_第2页
第2页 / 共11页
12864液晶屏(带字库)51单片机3线串口驱动程序_第3页
第3页 / 共11页
12864液晶屏(带字库)51单片机3线串口驱动程序_第4页
第4页 / 共11页
12864液晶屏(带字库)51单片机3线串口驱动程序_第5页
第5页 / 共11页
点击查看更多>>
资源描述

《12864液晶屏(带字库)51单片机3线串口驱动程序》由会员分享,可在线阅读,更多相关《12864液晶屏(带字库)51单片机3线串口驱动程序(11页珍藏版)》请在金锄头文库上搜索。

1、#includetypedef unsigned char uint8;typedef unsigned int uint16;typedef unsigned long uitn32;sbit CS = P10;/片选信号引脚sbit SDA = P11;/数据线sbit SCK = P12;/串行时钟线/sbit RST = P13;/复位引脚/sbit PSB = P14;/串并控制引脚code uint8 strint1 = I Love You !;/*void delay5ms(void) /误差 0us unsigned char a,b; for(b=185;b0;b-) fo

2、r(a=12;a0;a-);*/发送一个字节void Send_Byte(uint8 dat)uint8 i;SCK = 0;for(i=0;i8;i+)SDA = dat&0x80;SCK = 1;dat = 1;SCK = 0;/读取一个字节数据uint8 Read_Byte(void)uint8 i;uint16 byte = 0;SCK = 0;for(i=0;i16;i+)byte 4)|(byte8)&0x00ff;return (uint8)(byte);/读忙标志void Read_Busy(void)uint8 temp;CS = 1;doSend_Byte(0xfc);/发

3、送读命令temp = Read_Byte();/读取数据while(temp&0x80);CS = 0;/发送命令void Write_Cmd(uint8 cmd)uint8 temph = 0;uint8 templ = 0;/制作发送命令格式temph = cmd & 0xf0;templ = (cmd & 0x0f) 4;Read_Busy();CS = 1;Send_Byte(0XF8);/发送命令命令/发送命令Send_Byte(temph);Send_Byte(templ);CS = 0;/发送数据void Write_Dat(uint8 dat)uint8 temph = 0;u

4、int8 templ = 0;/制作发送数据格式temph = dat & 0xf0;templ = (dat & 0x0f) 4;Read_Busy();CS = 1;Send_Byte(0XFA);/发送数据命令Send_Byte(temph);/发送数据Send_Byte(templ);CS = 0;/在指定位置显示半字宽字符void Dis_HCGROM(uint8 x,uint8 y,uint8 dat)uint8 addr;switch(y)case 0:addr = 0x80 + x;break;case 1:addr = 0x90 + x;break;case 2:addr =

5、 0x88 + x;break;case 3:addr = 0x98 + x;break;default:break;Write_Cmd(addr);Write_Dat(dat);/指定位置显示字符串void Dis_String(uint8 x, uint8 y, uint8 len, uint8 *dat)uint8 addr,i;switch(y)case 0:addr = 0x80 + x;break;case 1:addr = 0x90 + x;break;case 2:addr = 0x88 + x;break;case 3:addr = 0x98 + x;break;defaul

6、t:break;Write_Cmd(addr);for(i = 0;i 8);Write_Dat(uint8)(dat);/LCD初始化void LCD_Init(void)/*RST = 0;delay5ms();delay5ms();RST = 1;PSB = 0;*/Write_Cmd(0X30);Write_Cmd(0X01);Write_Cmd(0X02);Write_Cmd(0X0C);void main(void)LCD_Init();while(1)Dis_GB(0,0,0xc9b5);Dis_HCGROM(1,0,0x03);Dis_String(0,1,13,strint1);Dis_UNum8(0,2,250);

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > IT计算机/网络 > 其它相关文档

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号