cancel
Showing results for 
Search instead for 
Did you mean: 

why is my interrupt not working???

josephpenafiel
Associate
Posted on September 10, 2015 at 07:26

hello,

I've been trying to blink an led using an overflow interrupt with timer 4 on the sm8l discovery board. So far I haven't made it work. I'm currently using IAR Embedded Workbench with the Std library for stm8l. I need help. here's what I'm trying to do: here's the main.c

#include ''stm8l15x.h''
void timer4_init(void){
TIM4_DeInit();
CLK_PeripheralClockConfig(CLK_Peripheral_TIM4, ENABLE);
TIM4_TimeBaseInit(TIM4_Prescaler_8, 100);
TIM4_ITConfig(TIM4_IT_Update, ENABLE);
}
int main(void) {
timer4_init();
GPIO_Init(GPIOC, GPIO_Pin_7, GPIO_Mode_Out_PP_High_Fast); 
enableInterrupts();
while(1){
}
}

and the interrupt handler is in the stm8l15x_it.c, I've also included in this file the stm8l15x.h header file.

INTERRUPT_HANDLER(TIM4_UPD_OVF_TRG_IRQHandler,25)
{
/* In order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction.
*/
GPIO_ToggleBits(GPIOC, GPIO_Pin_7);
TIM4_ClearITPendingBit(TIM4_IT_Update);
}

What am I doing wrong? thanks in advance #timer #interrupts #stm8l
1 REPLY 1
Ian Legg
Senior
Posted on September 10, 2015 at 11:28

Hi Joseph,

You might need:

  TIM4_EGR = 0x1; /* Force prescaler update */

And you will need:

  TIM4_CR1 |= 0x1; /* Enable counter */

Hope that helps,

Ian