Background
I'm relatively inexperienced with the STM32 series, so I'm sure that this is simple and I'm missing a setup somewhere.
I am trying to set up the timer to simply interrupt on an update event, which should be when the counter rolls over at the TIM2->ARR
value.
- I am currently setting a breakpoint inside the timer interrupt and it is simply not triggering
- I have tried to use other timer modules
- The counter is counting (I can observe through the debugger)
- The registers are loaded appropriately based on the below code
- The
TIM2->SR UIF
(update interrupt flag) is set when the counter rolls over
Code
void TIM_init(void){
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
TIM2->PSC = 1000;
TIM2->ARR = 1000;
TIM2->DIER = TIM_DIER_UIE;
TIM2->EGR = TIM_EGR_UG;
NVIC_EnableIRQ(TIM2_IRQn);
DBGMCU->CR |= DBGMCU_CR_DBG_TIM2_STOP;
TIM2->CR1 |= TIM_CR1_CEN;
}
void TIM2_IRQHandler(void){
TIM2->SR &= ~TIM_SR_UIF; // clear the interrupt flag
}
I also tried setting the priority grouping as follows, same results:
void TIM_init(void){
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
TIM2->PSC = 10;
TIM2->ARR = 1000;
TIM2->DIER = TIM_DIER_UIE;
TIM2->EGR = TIM_EGR_UG;
// Enable the Timer2 Interrupts
uint32_t priorityGroup, priority;
priorityGroup = NVIC_GetPriorityGrouping();
priority = NVIC_EncodePriority(priorityGroup, 3, 6);
NVIC_SetPriority(TIM2_IRQn, priority);
NVIC_EnableIRQ(TIM2_IRQn);
DBGMCU->CR |= DBGMCU_CR_DBG_TIM2_STOP;
TIM2->CR1 = TIM_CR1_CEN;
}
The project also contains an assembly file startup_stm32f10x.s
. An excerpt from that file:
__vector_table
DCD sfe(CSTACK)
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler.....
which continues on, including the TIM2_IRQHandler
. This indicates to me that there is a vector table there.
startup_stm32f10x_ld.s
file that is included within the project that apparently has a reference to theTIM2_IRQHandler
, is this what you mean? – slightlynybbled