#include <SH88F4051.H>
#include<math.h>
#define adstart ADCON|=0X01
#define ADCIF ADCON&0X40
#define cladcif() ADCON&=0XBF
#define adc ADDH*256+ADDL
unsigned int ad1;
unsigned char ad0;
void init(void);
int main()
{
init();
while(1)
{
adstart;
ad1=0;
ad0=0;
while(~ADCIF);
cladcif();
ad1=adc;
}
}
void init(void)
{
SP=0X60;
CLKCON=0X0C;
ADCON=0X80;//设置ADC
ADT=0XC1;//周期设置
ADCH=0X01;//通道配置
PWMCON=0XF1;
PWMD=0XFF;
PWMP=0X10;
IEN1=0X20;
IEN0=0X80;
}
void PWM_ISP(void) interrupt 1
{
PWMP=ADDH;
} |