潍坊学院本科毕业设计
开 始 初 始 化 设lr、X、Y初始值
lr—选取控制器 X—页面值,Y—列地址值
开 始 显 示 显示满16列? N Y X+1 显示下半部分 N 满16列? Y 汉显完成, 继续吗? N Y 返 回 图3.3 汉字显示流程图
3.2 显示程序的设计
按上面的流程图,就可以进行显示程序的设计了。 具体程序如下:
#define EN 3 #define DI 4
21
潍坊学院本科毕业设计
#define CSA 5 #define CSB 6 #define RW 7
unsigned char hzzhi[]={};//智 unsigned char hznen[]={};//能 unsigned char hzxin[]={};//型 unsigned char hzchong[]={};//充 unsigned char hzdian[]={};//电 unsigned char hzqi[]={};//器 unsigned char hzchi[]={};//池 unsigned char hzzhuang[]={};//状 unsigned char hztai[]={};//态 unsigned char hzya[]={};//压 unsigned char hzliu[]={};//流 unsigned char hzwen[]={};//温 unsigned char hzdu[]={};//度 unsigned char hzman[]={};//满 unsigned char hzjuan[]={};//涓 unsigned char hzkuai[]={};//快 unsigned char hzfang[]={};//放 unsigned char hznie[]={};//镍 unsigned char hzge[]={};//镉 unsigned char hzqing[]={};//氢 unsigned char hzli[]={};//锂 unsigned char DATA; //PORTB-->data
//PA3->EN;PA4->DI;PA5->CSA;PA6->CSB;PA7->RW; //写LCD指令
void WriteCom(unsigned char area,unsigned char com) {
22
潍坊学院本科毕业设计
//area=0-->left;1-->mid;2-->right //area=[csa,csb]00:L 01:M 10:R unsigned char lcd_busy; switch(area) case 0:
PORTA &=~ (1< PORTA &=~ (1< PORTA |= (1< PORTA |= (1< PORTA &=~ (1< PORTC &=~ (1< PORTB=0xFF; PORTA |= (1< PORTC |= (1< 23 潍坊学院本科毕业设计 }while(lcd_busy==1); PORTC &=~ (1< //写LCD数据 void WriteDat(unsigned char area,unsigned char dat) { //area=0-->left;1-->mid;2-->right //area=[csa,csb]00:L 01:M 10:R unsigned char lcd_busy; switch(area) { case 0: