泳镜厂家
免费服务热线

Free service

hotline

010-00000000
泳镜厂家
热门搜索:
行业资讯
当前位置:首页 > 行业资讯

ATmega128并行控制带字库的12864程序

发布时间:2020-02-03 05:36:35 阅读: 来源:泳镜厂家

ATmega128的特点是io口很多,所以我们可以用并行的方式来驱动此液晶屏,增加总线的速度,此程序是是网上整理收集而来,但已经通过本人验证可以使用,故在此发表.大家在应用的时候只需更改相应的io就行了.软件:GCC V4.20--------------------------------------------------------------- 实验内容:写Lcd12864_ST7920。---------------------------------------------------------------硬件连接:LCD12864_ST7920 D -------- C -------- VCC3.V0 -------- (CS) -------- PD75.R/W(SID) -------- PG06.E(SCLK) -------- PG17.D0 -------- PC08.D1 -------- PC19.D2 -------- PC210.D3 -------- PC311.D4 -------- PC412.D5 -------- PC513.D6 -------- PC614.D7 -------- B -------- -------- T -------- -------- D+ -------- D- -------- GND以下是程序源代码:---------------------------------------------------------------*/ #include avr/io.h>#includeavr/pgmspace.h>#include util/delay.h> #define E_set PORTG|=_BV(PG1) //液晶使能#define E_clear PORTG=~_BV(PG1)#define RW_set PORTG|=_BV(PG0) //液晶读写#define RW_clear PORTG=~_BV(PG0)#define RS_set PORTD|=_BV(PD7) //液晶数据#define RS_clear PORTD=~_BV(PD7) //液晶指令unsigned char j=0;unsigned char yb=0x80;unsigned char name00[] PROGMEM={"飞射白鹿雪连天,"};unsigned char name01[] PROGMEM={"笑书神侠倚碧鸳。"};unsigned char name02[] PROGMEM={"自古英雄多奇逸,"};unsigned char name03[] PROGMEM={"金老挥毫尽使然。"};unsigned char name10[] PROGMEM={"李白乘舟将欲行,"};unsigned char name11[] PROGMEM={"忽闻岸上踏歌声。"};unsigned char name12[] PROGMEM={"桃花潭水深千尺,"};unsigned char name13[] PROGMEM={"不及汪伦送我情。"};unsigned char name20[] PROGMEM={"this is a 12864 "};unsigned char name21[] PROGMEM={"display program,"};unsigned char name22[] PROGMEM={"welcome to commu"};unsigned char name23[] PROGMEM={"nicate with me! "};void wr_com(unsigned char);void wr_data(unsigned char);void reset (void);void outChinese(unsigned char,unsigned char,unsigned char *point);void ydgb(void);void outchar(unsigned char,unsigned char,unsigned char *point);void wr_com(unsigned char value)//写指令,写指令时必须为RS=0;RW=0;{E_clear;RS_clear;RW_clear;_delay_ms(1);PORTC=value; //并入字符数据E_set;_delay_ms(2); //如果没有延时就必须要加查忙指令E_clear;}void wr_data(unsigned char sj)//写数据,写数据时必须为 RS=1;RW=0;{E_clear;RS_set;RW_clear;_delay_ms(1);PORTC=sj;E_set;_delay_ms(1);//如果没有延时就必须要加查忙指令E_clear;}void reset (void){wr_com(0x01);//清屏wr_com(0x08);//关显示wr_com(0x03);//归位wr_com(0x30);//功能设置wr_com(0x0f);//开显示wr_com(0x01);//清屏}//****************//outChinese 为函数名//place 为显示地址的首地址//unit 字符长度//charcode[] 要显示数据的内容

梦乃爱华步兵番号

佐佐木绘奈磁力

天海翼

相关阅读