tenbaht/sduino

TIMER 2 interrupts not working

Opened this issue · 0 comments

Hi have used stm8s103 in sduino , i cannot able to write ISR for timer2 please help
INTERRUPT_HANDLER(TIM2_UPD_OVF_IRQHandler, 13) /* TIM4 UPD/OVF */
{

i++;
TIM2_ClearITPendingBit(TIM2_IT_UPDATE);
TIM2_ClearFlag(TIM2_FLAG_UPDATE);

}
void TIM2_Config(void)
{
//set at 100usec on overflow aims

/* TIM2 configuration:

  • TIM2CLK is set to 16 MHz, the TIM2 Prescaler is equal to 16 so the TIM2 counter
    clock used is 16 MHz / 16 = 1000 000 Hz
  • With 1000 000 Hz we can generate time base:
    max time base is 65536us if TIM2_PERIOD = 65535 --> (65535 + 1) * 1000000 = 65536 us
    min time base is 2 us if TIM2_PERIOD = 1 --> ( 1 + 1) * 1000000 = 2 us
  • In this example we need to generate a time base equal to 256 us
    so TIM4_PERIOD = (0.001 * 125000 - 1) = 124 */

/* Time base configuration /
TIM2_TimeBaseInit(TIM2_PRESCALER_16, TIM2_PERIOD);
/
Clear TIM4 update flag /
TIM2_ClearFlag(TIM2_FLAG_UPDATE);
/
Enable update interrupt */
TIM2_ITConfig(TIM2_IT_UPDATE, ENABLE);

/* enable interrupts */
// enableInterrupts();

/* Enable TIM4 */
TIM2_Cmd(ENABLE);
}