Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TIMER 2 interrupts not working #158

Open
anupam-dubey opened this issue Feb 22, 2024 · 0 comments
Open

TIMER 2 interrupts not working #158

anupam-dubey opened this issue Feb 22, 2024 · 0 comments

Comments

@anupam-dubey
Copy link

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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant