STM8- Unable to use timer2 with intrrupt

by erdarshp   Last Updated September 23, 2018 15:25 PM

I am trying to run timer interrupt in STM8 Controller. But I am not able to do So. I tried to read the counter Register and ARRP but after loading the value as well both register has the initial value not the loaded one. Here is the code snippet.

 void TIM2_Configuration(void) { 
     TIM2_DeInit();
     CLK_PeripheralClockConfig(CLK_PCKENR1_TIM2, ENABLE);
     TIM2_ARRPreloadConfig(ENABLE);
     TIM2_TimeBaseInit(TIM2_Prescaler_128, TIM2_CounterMode_Down, 500);      
     TIM2_ITConfig(TIM2_FLAG_Trigger, ENABLE);
     TIM2_Cmd(ENABLE);
     enableInterrupts();
 }

and enabling Clock peripheral in main function

CLK_PeripheralClockConfig(CLK_Peripheral_TIM2, ENABLE);

And Added a keyword @svlreg(as facing @svlreg missing for interrupt) in Interrupt Handler where i hav added the interrupt code

 @svlreg INTERRUPT_HANDLER(TIM2_UPD_OVF_TRG_BRK_USART2_TX_IRQHandler, 19)

Can you please let me know if anything I am missing in an initialized Timer interrupt.



Related Questions



Measure Time duration between two pulses

Updated August 13, 2016 08:10 AM

STM32 one timer for multiple push buttons

Updated July 23, 2017 06:25 AM