AnsweredAssumed Answered

Failing to call interrupt handler

Question asked by dan on Sep 4, 2015
Latest reply on Sep 4, 2015 by dan
Hi all,

I have implemented a simple routine to drive a buzzer. The routine will enable a timer and will toggle state of the pin connected to the buzzer at different frequencies. The buzzer code is:

void buzz(uint32_t freq, uint32_t t, uint32_t duty_cycle) {
  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE);

  TIM2_init(freq, duty_cycle);

  TIM_ITConfig(TIM2, TIM_IT_Update, ENABLE);
  TIM_Cmd(TIM2, ENABLE);

  delay_ms(t);

  TIM_DeInit(TIM2);
  TIM_ITConfig(TIM2, TIM_IT_Update, DISABLE);
  TIM_Cmd(TIM2, DISABLE);

  RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, DISABLE);
}

and the interrupt handler where the pin state is toggles is:

void TIM2_IRQHandler() {
  TIM_ClearITPendingBit(TIM2, TIM_IT_Update);
  ToggleBuzzerBit();
}

The code works fine as it should from the main function in the code, but I would like to call buzzer in another interrupt handler. In that case, when I call buzzer from another
interrupt handler, it never works and I can see through code tracing that the timer never starts and therefore the buzzer pin never toggles inside the interrupt handler above.
I am wondering whether there is any solution for that, or it is a limitation that an interrupt handler cannot be called by another interrupt handler?

Thanks for your help,

Dan.

Outcomes