2018-09-25 07:35 AM
I am trying to run timer interrupt in STM8 microcontroller. But I am not able to do so.
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_Update, 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 have added the interrupt code:
@svlreg INTERRUPT_HANDLER(TIM2_UPD_OVF_TRG_BRK_USART2_TX_IRQHandler, 19)
I tried to read the counter Register and ARRP, but after loading the value as well both registers had the initial value, not the loaded one.
again I tried to change the value of initial ARRP in DeInit function to 0xFE but still I am getting 0xFF.
Means may be I am not able to write the value in Timer 2 register.
Can you please let me know if anything I am missing in an initialized Timer interrupt?
2018-10-05 10:33 AM
"Can you please let me know if anything I am missing in an initialized Timer interrupt?"
learn to help others help you. like providing full (minimalist) code, what your observed and what you expected, your environment, ...
i would try to see if you can program the chip at all; and if you can blink an led; and go from there...