配置两个定时器,定时器0定时0.2ms ,定时器1定时20ms,在没有写入ADC及中断之前两个定时器正常工作,但是加了ADC以后,就不能进入定时器1的中断。不懂是什么问题?求各路神仙解救~
void Timer0_Init()
{
TIMER0_MODE1_ENABLE;
clr_T0M; //设置定时器0为系统时钟的12分频
u8TH0_Tmp = (65536-TH0_INIT)/256;
u8TL0_Tmp = (65536-TL0_INIT)%256;
TH0 = u8TH0_Tmp;
TL0 = u8TL0_Tmp;
set_ET0; //开启 Timer0 中断
set_EA; //开启 总中断
set_TR0;
}
void Timer1_Init(void)
{
TIMER1_MODE1_ENABLE;
clr_T1M;
u8TH1_Tmp = (65536-TH1_INIT)/256;
u8TL1_Tmp = (65536-TL1_INIT)%256;
TH1 = u8TH1_Tmp;
TL1 = u8TL1_Tmp;
set_ET1; //enable Timer1 interrupt
set_EA;
set_TR1; //Timer1 run
}
/************************************************************************************************************
* TIMER 0 interrupt subroutine
************************************************************************************************************/
void Timer0_ISR (void) interrupt 1 //interrupt address is 0x000B
{
clr_TF0;//清除中断标志位
TH0 = u8TH0_Tmp;//重装初值
TL0 = u8TL0_Tmp;
// Start_PWM();
ZT_PreChCount();
ADCProcess();
}
void Timer1_ISR (void) interrupt 3 //interrupt address is 0x001B
{
clr_TF1;
TH1 = u8TH1_Tmp;
TL1 = u8TL1_Tmp;
PowerCnt++;
LedCnt++;
if(LedCnt>0x20)
{
LedCnt=0;
LED_Spark_Process();
}
KeyCatch();
}
void ADCInit(void)
{
Enable_ADC_AIN2;
clr_ADCF; // ADCF = 0 AD转换未完成
set_EADC;//使能ADC中断
EA = 1;
set_ADCS; //启动AD转换
iCheckCH0=0;
LostCnt=0;
// while(ADCF == 0);
// set_EADC;
}
void ADC_ISR (void) interrupt 11
{
if(ADCF)
{
clr_ADCF;//清除ADC转化完成标志,进行下一次转换
set_ADCS;//当单次转换完成后,ADCS会硬件置0,需要重新使能
ADCResult=(UINT16)(ADCRH & 3);
ADCResult = (ADCResult << 8) | ADCRL;
}
}
附上自己的代码,现在调试进入不了定时器1的中断 |