求助关于stc12单片机ad转换LCD显示问题
时间:10-02
整理:3721RD
点击:
关于stc12单片机ad转换显示问题 功能已实现 但是还是有点不明白 不是ad转换问题而是显示的问题程序如下 谢谢大牛解答 :“a=GetADCResult();” 就是这里 当我把这一行放在while死循环第一句的时候LCD不显示 放在第二行 只显示0 放在打三行字显示“ou"放在第4行到最后一行的时候可以正常显示 不知道问什么 请大牛解答; 谢谢啦 ! #include<STC12C5A.H>
#include"LCD.h"
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
void delay1(uint n)
{
uint x;
while(n--)
{
x=5000;
while(x--);
}
}
void InitADC()
{
P1ASF=0x01;
ADC_RES=0;
ADC_CONTR=0X80;
AUXR1&=!0x40;
delay1(2);
}
uchar GetADCResult()
{
ADC_CONTR=0x88;
_nop_();
_nop_();
_nop_();
_nop_();
while (!(ADC_CONTR & 0x10));
ADC_CONTR&=!0x10;
return ADC_RES;
}
void main()
{
uint a;
Init_Lcd();
LCD1602();
InitADC();
IE=0xa0;
while(1)
{
Display_Lcd_Byte(0,0,'O');
Display_Lcd_Byte(0,1,'U');
Display_Lcd_Byte(0,2,'T');
a=GetADCResult(); 就是这里 当我把这一行放在while死循环第一句的时候LCD不显示 放在第二行 只显示0 放在打三行字显示“ou"放在第4行到最后一行的时候可以正常显示 不知道问什么 请大牛解答; 谢谢啦 !
Display_Lcd_Byte(0,3,':');
Display_Lcd_Byte(0,4,(a*195)/10000+0x30);
Display_Lcd_Byte(0,5,'.');
Display_Lcd_Byte(0,6,(a*195)/1000%10+0x30);
Display_Lcd_Byte(0,7,(a*195)/100%10+0x30);
Display_Lcd_Byte(0,8,'V');
}
}
#include"LCD.h"
#include<intrins.h>
#define uchar unsigned char
#define uint unsigned int
void delay1(uint n)
{
uint x;
while(n--)
{
x=5000;
while(x--);
}
}
void InitADC()
{
P1ASF=0x01;
ADC_RES=0;
ADC_CONTR=0X80;
AUXR1&=!0x40;
delay1(2);
}
uchar GetADCResult()
{
ADC_CONTR=0x88;
_nop_();
_nop_();
_nop_();
_nop_();
while (!(ADC_CONTR & 0x10));
ADC_CONTR&=!0x10;
return ADC_RES;
}
void main()
{
uint a;
Init_Lcd();
LCD1602();
InitADC();
IE=0xa0;
while(1)
{
Display_Lcd_Byte(0,0,'O');
Display_Lcd_Byte(0,1,'U');
Display_Lcd_Byte(0,2,'T');
a=GetADCResult(); 就是这里 当我把这一行放在while死循环第一句的时候LCD不显示 放在第二行 只显示0 放在打三行字显示“ou"放在第4行到最后一行的时候可以正常显示 不知道问什么 请大牛解答; 谢谢啦 !
Display_Lcd_Byte(0,3,':');
Display_Lcd_Byte(0,4,(a*195)/10000+0x30);
Display_Lcd_Byte(0,5,'.');
Display_Lcd_Byte(0,6,(a*195)/1000%10+0x30);
Display_Lcd_Byte(0,7,(a*195)/100%10+0x30);
Display_Lcd_Byte(0,8,'V');
}
}
把你显示函数发出来看看,应该是你显示的问题
每显示完后一个字符加一个小延时试下。
