cancel
Showing results for 
Search instead for 
Did you mean: 

Try to generate TIM1 overflow/underflow update event interrupt in center-aligned mode

CKuo.1
Associate

Hi all,

I tried to configure STM8AF62Ax's TIM1 in center-aligned mode to generate 1kHz PWM output.

​Also I'd like to generate a 2kHz interrupt by both overflow and underflow update event in TIM1.

Now I can measure PWM patterns on scope, but the interrupt routine "TIM1_UPD_OVF_TRG_BRK_IRQHandler" is not being executed (not even once).

I'm using STM8S standard peripheral libraries. The following function shows how I initiate TIM1.

----------------------------------------------------------------------------------------------------

void TIM1_Config(void)

{

TIM1_DeInit();

TIM1_TimeBaseInit(15, TIM1_COUNTERMODE_CENTERALIGNED1, 499, 0);

TIM1_ARRPreloadConfig(ENABLE);

TIM1_OC1Init(TIM1_OCMODE_PWM1,TIM1_OUTPUTSTATE_ENABLE, TIM1_OUTPUTNSTATE_DISABLE, 249, TIM1_OCPOLARITY_HIGH, TIM1_OCNPOLARITY_LOW, TIM1_OCIDLESTATE_SET, TIM1_OCNIDLESTATE_RESET);

TIM1_GenerateEvent(TIM1_EVENTSOURCE_UPDATE);

TIM1_UpdateDisableConfig(DISABLE);

TIM1_UpdateRequestConfig(TIM1_UPDATESOURCE_GLOBAL);

TIM1_ITConfig(TIM1_IT_UPDATE, ENABLE);

TIM1_Cmd(ENABLE);

}

----------------------------------------------------------------------------------------------------

And I do have the function "TIM1_ClearITPendingBit" at the end of interrupt routine.

I cannot figure out why "TIM1_UPD_OVF_TRG_BRK_IRQHandler" is not being executed.

Can anyone tell if I miss some settings that is necessary for generating update interrupt ?

Thanks a lot for your kind assistance.

1 REPLY 1
Cristian Gyorgy
Senior III

I don't know the library functions and how to use them, but yours should be fine. How do you know the interrupt is not executed? Are interrupts enabled?