最近用新唐MS51FB9AE芯片ADC功能在Keil5仿真时,有时程序运行ADC程序采样正常OK,但有时很随机的会一直停在while(ADCF == 0)死循环跳不出来,一时找不出问题原因,请大家帮忙指点,下面是仿真ADC子程序
uint16 ReadAdcValue(void)
{
uint16 AdcTemp;
ADCCON1|=0X30;
ADCCON2|=0X0E;
AUXR1|=SET_BIT4;
clr_ADCF;
set_ADCS;
while(ADCF == 0);
AdcTemp = ADCRH;
AdcTemp <<= 4;
AdcTemp |= ( ADCRL & 0x0F);
Disable_ADC;
return AdcTemp;
}
void CheckBattAdc (void)
{
uint16 AdcTemp;
Enable_ADC_AIN5;
AdcTemp=ReadAdcValue();
} |