智能车制作

标题: 求液晶1602在S12上的驱动程序 [打印本页]

作者: huyangtu    时间: 2008-5-19 05:09
标题: 求液晶1602在S12上的驱动程序
<>想用液晶1602显示小车相关数据,但是把1602的驱程从51系列移植到S12上一直都没成功,不知有哪位大侠有成功移植的共享下代码</P><P>谢谢</P>
作者: 123220063    时间: 2008-10-13 04:48
标题: Re:求液晶1602在S12上的驱动程序
<>这里有个12864的那个1602也应该差不多把</P><P>#include &lt;hidef.h&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* common defines and macros */<BR>#include &lt;mc9s12dg128.h&gt;&nbsp;&nbsp;&nbsp;&nbsp; /* derivative information */<BR>#pragma LINK_INFO DERIVATIVE "mc9s12dg128b" <BR>#define LCD_DB PTH<BR>#define LCDRW PTT_PTT6 <BR>#define&nbsp;LCDRS PTT_PTT5 </P><P>unsigned char TimeTable[6]={&#39;&#92;0&#39;},num=0;<BR>unsigned char TimeTable1[3][6]={&#39;&#92;0&#39;},num1=0;</P><P>void delay1ms(uchar time)<BR>{&nbsp; int delay1ms1,delay1ms2;<BR>&nbsp;&nbsp; for (delay1ms1=0;delay1ms1&lt;time;delay1ms1++)<BR>&nbsp;&nbsp;&nbsp;&nbsp; for (delay1ms2=0;delay1ms2&lt;300;delay1ms2++) ;<BR>}<BR>void Lcd_command(uchar com_data)<BR>{<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;LCD_DB=com_data;<BR>&nbsp;LCDRS=0;<BR>&nbsp;LCDRW=0;<BR>&nbsp;E=1;<BR>&nbsp;E=0;<BR>&nbsp;E=1;<BR>&nbsp;LCDRW=1;<BR>&nbsp;LCD_DB=0xff;<BR>&nbsp;LCDRS=0;<BR>&nbsp;DDRH=0x00;<BR>&nbsp;while(PTIH&gt;=0x80);<BR>&nbsp;DDRH=0xff;&nbsp;<BR>&nbsp;E=0;<BR>&nbsp;E=1;&nbsp;<BR>}</P><P>void Lcd_send(uchar send_data)<BR>{<BR>&nbsp; &nbsp;<BR>&nbsp;<BR>&nbsp;LCD_DB=send_data;<BR>&nbsp;LCDRS=1;<BR>&nbsp;LCDRW=0;<BR>&nbsp;E=1;<BR>&nbsp;delay1ms(1);<BR>&nbsp;E=0;<BR>&nbsp;delay1ms(10);<BR>&nbsp;E=1;<BR>&nbsp;LCDRW=1;<BR>&nbsp;LCD_DB=0xff;<BR>&nbsp;LCDRS=0;<BR>&nbsp;DDRH=0x00;<BR>&nbsp;while(PTIH&gt;=0x80);<BR>&nbsp;DDRH=0xff;<BR>&nbsp;E=0;<BR>&nbsp;E=1;<BR>&nbsp;</P><P>&nbsp;delay1ms(2);<BR>}</P><P>void Lcd_init()<BR>{&nbsp;&nbsp; delay1ms(10);&nbsp;&nbsp; <BR>&nbsp;<BR>&nbsp;&nbsp;&nbsp; E=0;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <BR>&nbsp;LCDRS=1;<BR>&nbsp;LCDRW=1;<BR>&nbsp;&nbsp;&nbsp; delay1ms(50); <BR>&nbsp;Lcd_command(0x30);<BR>&nbsp;delay1ms(100);<BR>&nbsp;Lcd_command(0x30);<BR>&nbsp;delay1ms(100);<BR>&nbsp;Lcd_command(0x0c);<BR>&nbsp;delay1ms(100);<BR>&nbsp;Lcd_command(0x01);<BR>&nbsp;delay1ms(100);<BR>&nbsp;Lcd_command(0x06);<BR>&nbsp;delay1ms(100);&nbsp; <BR>}&nbsp;<BR>void Display(uchar x,uchar y)<BR>{<BR>if(y==0)<BR>&nbsp;&nbsp;&nbsp; Lcd_command(0x80|x);<BR>if(y==1)<BR>&nbsp;&nbsp;&nbsp; Lcd_command(0x88|x);<BR>if(y==2)<BR>&nbsp;&nbsp;&nbsp; Lcd_command(0x90|x);<BR>if(y==3)<BR>&nbsp;&nbsp;&nbsp; Lcd_command(0x98|x);<BR>}</P><P>void Lcd_display(unsigned char *str)<BR>{<BR>&nbsp;&nbsp; while(*str!=&#39;&#92;0&#39;)<BR>&nbsp;&nbsp; {&nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp; Lcd_send(*str);<BR>&nbsp; str++;<BR>&nbsp;}<BR>}</P>
作者: bengzhu1hao    时间: 2009-5-2 11:14
我怎么没发现主函数
作者: xbsf-写轮眼    时间: 2009-5-13 14:07
建议你好好把1602的时序研究研究,写作框架可以参考基于51的程序!




欢迎光临 智能车制作 (http://111.231.132.190/) Powered by Discuz! X3.2