一个小的测试ADC和PWM的程序,芯片是88F4051,老是重启,无法运行。后查看编译后的汇编文件,发现有这么一句:C:0x005E 02000E LJMP main(C:000E)0A,不知为何?
程序如下:
#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;
}
寻求解答 |