接5v电压,串口打印ADC值显示
接ch552芯片20脚3.3v串口打印显示
********************************************************************************/
#include "CH554.H"
#include "Debug.H"
#include "GPIO.H"
#include "HT1621.H"
#include "ADC.H"
#include "stdio.h"
#include
#include
#define uchar unsigned char
#define uint unsigned int
void main( )
{
ADCInit(0);
CfgFsys( );
mDelaymS(20);
mInitSTDIO( );
CH554UART0Alter(); //串口映射
EA=1; //开启全局中断
while(1)
{
{
ADC_ChannelSelect(3); //ADC采样电源开启和通道设置,采样通道AIN3
ADC_START = 1; //开启采样,等待采样完成进入中断
while(ADC_START); //采样完成,ADC_START=0
num=ADC_DATA;
mDelaymS(1000); //等待,进入下通道采集数据
}
printf("ADC\n");
mDelaymS(1000);
printf("DATA: %d\n",(UINT16)ADC_DATA);
mDelaymS(1000);
}
}