大神帮忙看看,调试的时候一直停留在 while(!(0x80&ADC_CSR))
#include"stm8s903k.h"
void AD_Init(void)
{
ADC_CSR|=0x06; //状态寄存器
ADC_CR1=0x00; //预分频;开关 频率fmaster/2
ADC_CR2=0x30; //左对齐
}
unsigned char AD_C(unsigned char chanel)
{
unsigned char ad_voltage;
ad_voltage=0;
ADC_CSR=chanel;
ADC_CSR&=0x7F;
ADC_CR1|=0x01; //启动ADC
while(!(0x80&ADC_CSR));//判断是否结束转换
ad_voltage=ADC_DRH;
ADC_DRL;
return(ad_voltage);
}
void main()
{
unsigned char PW_AD;
PW_AD=0;
AD_Init();
while(1)
{
PW_AD=AD_C(0x03);
}
} |