Ad测试代码
#include
#include
#include
#define uchar unsigned char
/*Set up UART */
/*系列初始化*/
void serial_initial(void)
{
aduPLLCON=0X00;
// T3CON = 0x085;//831,晶振11.0592M,波特率9600
T3CON = 0x086;//841
T3FD = 0x2D;
SCON = 0x052;
}
void DELAY(int length) //延时程序
{
while (length >=0)
length--;
}
/*AD中断程序,输出10进制AD采样值 */
void adc_int() interrupt 6
{
unsigned int out=0;
unsigned int channel;
channel=ADCDATAH>>4;//ADCDATAH高四位为通道号
printf("\n%u ",channel);//输出通道号
out=ADCDATAH&0x0F;
out=out*256+ADCDATAL;
printf("\n%u ",out);//输出采样值
// Uart_write(ADCDATAH); //显示原始数据
// Uart_write(ADCDATAL);
return;
1