想要实现AD0808输入的电压值,经AD转换后在LCD1602上输出程序过长,仿真图中有引定义,延时函数,我就把程序中的引脚定义删除了一部分,剩下一点容易识别那个是lcd,那个是ad的。 程序有些也写到了一行上去#include<reg52.h> #include<math.h>#define uint unsigned int #define uchar unsigned charsbit lcdrs = P3^0;....等 //lcd1602引脚定义sbit ADA = P2^0;...等 //ad0809引脚定义sbit key1 = P3^3;..等 //键盘引脚定义uchar tab1[] = {48,46,48,48,48,46,48,48,48,46,48,48,48,46,48,48}; //定义数据uchar tab2[] = {48,46,48,48,48,46,48,48,48,46,48,48,48,46,48,48}; //存放AD数据uchar tab3[] = "TONGLU:"; uchar tab5[] = "123456"; uchar tab4[] = "Voltage:";uchar num,m=0,getdata=0; uint temp = 0;void delayms(uint t)//延时函数void delay1(uint ltime)void write_com(uchar com)//写命令函数{ lcdrs = 0; P0 = com; delayms(5); lcden = 1; delayms(5); lcden = 0; }void write_data(uchar date) //写数据函数{ lcdrs = 1; P0 = date; delayms(5); lcden = 1; delayms(5); lcden = 0; }void display(uchar h,l,uchar *p) //显示函数{ write_com(0x80+h*0x40+l); while(*p != '\0') { write_data(*p); p++; }} void lcdinit(){ lcdwr = 0; delayms(5); lcden = 0; write_com(0x38); //显示模式设置16*2显示 write_com(0x0c); //开显示,光标,不闪烁 write_com(0x06); //读一个字符指针自动加1,屏幕不移动 write_com(0x01); //是不是写错了?做完校验一下 delay1(20);} void time_T1(){这里定时器定时200微秒}void AdTr(bit adda,addb,addc,uchar channel){ START = 0; OE = 1; START = 1; START = 0; // A/D转换启动信号正脉冲启动选中的模拟信号开始转换 ADA = adda; ADB = addb; ADC = addc; delayms(5); while(EOC == 0); //等待AD转换完成 OE = 1; getdata = P1; temp = getdata*1.0/255*500; OE = 0; if(channel<4) { tab1[4*channel]=temp/100+0x30; tab1[4*channel+2]=(temp%100)/10+0x30; tab1[4*channel+3]=(temp%100)%10+0x30; } if(channel>=4) { channel=channel-4; tab2[4*channel]=temp/100+0x30; tab2[4*channel+2]=(temp%100)/10+0x30; tab2[4*channel+3]+(temp%100)%10+0x30; }}void keyscan()/* 按键2进行减1*/ { 按键部分只是对AD0808的通道选择,应该不影响lcd显示吧 } void main() { lcdinit(); time_T0(); while(1) { AdTr(0,0,0,0); delayms(5); AdTr(0,0,1,1); delayms(5); AdTr(0,1,0,2); delayms(5); AdTr(0,1,1,3); delayms(5); AdTr(1,0,0,4); delayms(5); AdTr(1,0,1,5); delayms(5); AdTr(1,1,0,6); delayms(5); AdTr(1,1,1,7); delayms(5); display(0,0,tab3); display(1,0,tab4); keyscan(); } } void t1(void) interrupt 3 using 0 { TH1=(65536-200)/256; TL1=(65536-200)%256; CLK=~CLK; }
可以发程序跟,仿真。。。让大神给调试
大神例子去哪了?
追答去我的共享空间下载一个例子,在这里才可以发链接的。
http://pan.baidu.com/s/1sllCGCP
不行的额。。。看不出= =
追答你会不会联调?
追问我可以给你程序跟,仿真,大神能帮我看看不
LCD1602仿真,屏幕亮但是不显示字幕跟数字。程序跟仿真截图在下面,请...
你那真图中的LCD的VDD,VSS,VEE,也没有接电源哪,那能显示字符吗,什么不接是会亮的,但不显示字符的。
LCD1602仿真没问题,实物连接也没问题,但是实物只能点亮不能显示内容...
你需要在V0端口接一个电位器,然后慢慢转动电位器,调节对比度,直到清晰的看到字幕即可(接线方法,电位器最左边接gnd,中间接V0接口,第三个不接)