本帖最后由 action99 于 2015-11-3 14:13 编辑
用STM8S003进入TIM4中断后不能对UIF清0,死循环在TIM4中断里面,请高手来解决。。谢谢。
void TIM4_Configuration(void)
{
/*
TIM4_TimeBaseInit(TIM4_PRESCALER_128 ,200); //煦128 RES=200
TIM4_ARRPreloadConfig(ENABLE); //赻雄蚾婥妏夔
TIM4_PrescalerConfig(TIM4_PRESCALER_128,TIM4_PSCRELOADMODE_IMMEDIATE);
TIM4_SetAutoreload(200);
TIM4_Cmd(ENABLE); //數杅妏夔
TIM4_ITConfig(TIM4_IT_UPDATE,ENABLE); //笢剿羲宎
*/
TIM4->IER=0x00;//輦砦笢剿
TIM4->EGR=0X01;//埰勍奀夔載陔岈璃
TIM4->PSCR=0x07;// 數杅奀笘=翋奀笘/128=16MHZ/128=125KHZ=8us
TIM4->ARR=51;//赻雄蚾婥硉˙隅奀笚=8us*51=408us
TIM4->CNTR=51;//數杅場硉
TIM4->CR1=0x01;//奀夔數杅
}
INTERRUPT_HANDLER(TIM4_UPD_OVF_IRQHandler, 23) //隅奀21.2US
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
//TimingDelay_Decrement();
TIM4_ClearITPendingBit(TIM4_IT_UPDATE);
TIM4->SR1 &=0xfe;
}
int main(void)
{
/* 扢离俋窒16M儒淥峈炵苀翋奀笘 */
SystemClock_Init(HSE_Clock);
Key_Init();
LED_Init();
Tim1_Init(); //PC1~4岆PWM 怀堤
TIM4_Configuration();
enableInterrupts(); /* 羲軞笢剿 */
while (1)
{
Operation();
}
}
|