中级会员
- 积分
- 246
- 威望
- 203
- 贡献
- 35
- 兑换币
- 0
- 注册时间
- 2008-5-31
- 在线时间
- 4 小时
|
Re:求液晶1602在S12上的驱动程序
<>这里有个12864的那个1602也应该差不多把</P><P>#include <hidef.h> /* common defines and macros */<BR>#include <mc9s12dg128.h> /* derivative information */<BR>#pragma LINK_INFO DERIVATIVE "mc9s12dg128b" <BR>#define LCD_DB PTH<BR>#define LCDRW PTT_PTT6 <BR>#define LCDRS PTT_PTT5 </P><P>unsigned char TimeTable[6]={'\0'},num=0;<BR>unsigned char TimeTable1[3][6]={'\0'},num1=0;</P><P>void delay1ms(uchar time)<BR>{ int delay1ms1,delay1ms2;<BR> for (delay1ms1=0;delay1ms1<time;delay1ms1++)<BR> for (delay1ms2=0;delay1ms2<300;delay1ms2++) ;<BR>}<BR>void Lcd_command(uchar com_data)<BR>{<BR> <BR> LCD_DB=com_data;<BR> LCDRS=0;<BR> LCDRW=0;<BR> E=1;<BR> E=0;<BR> E=1;<BR> LCDRW=1;<BR> LCD_DB=0xff;<BR> LCDRS=0;<BR> DDRH=0x00;<BR> while(PTIH>=0x80);<BR> DDRH=0xff; <BR> E=0;<BR> E=1; <BR>}</P><P>void Lcd_send(uchar send_data)<BR>{<BR> <BR> <BR> LCD_DB=send_data;<BR> LCDRS=1;<BR> LCDRW=0;<BR> E=1;<BR> delay1ms(1);<BR> E=0;<BR> delay1ms(10);<BR> E=1;<BR> LCDRW=1;<BR> LCD_DB=0xff;<BR> LCDRS=0;<BR> DDRH=0x00;<BR> while(PTIH>=0x80);<BR> DDRH=0xff;<BR> E=0;<BR> E=1;<BR> </P><P> delay1ms(2);<BR>}</P><P>void Lcd_init()<BR>{ delay1ms(10); <BR> <BR> E=0; <BR> LCDRS=1;<BR> LCDRW=1;<BR> delay1ms(50); <BR> Lcd_command(0x30);<BR> delay1ms(100);<BR> Lcd_command(0x30);<BR> delay1ms(100);<BR> Lcd_command(0x0c);<BR> delay1ms(100);<BR> Lcd_command(0x01);<BR> delay1ms(100);<BR> Lcd_command(0x06);<BR> delay1ms(100); <BR>} <BR>void Display(uchar x,uchar y)<BR>{<BR>if(y==0)<BR> Lcd_command(0x80|x);<BR>if(y==1)<BR> Lcd_command(0x88|x);<BR>if(y==2)<BR> Lcd_command(0x90|x);<BR>if(y==3)<BR> Lcd_command(0x98|x);<BR>}</P><P>void Lcd_display(unsigned char *str)<BR>{<BR> while(*str!='\0')<BR> { <BR> Lcd_send(*str);<BR> str++;<BR> }<BR>}</P> |
|