How can I get the Timer status register (SR) in an interrupt routine or why it is not working?
Hi, i am very new to microcontrollers and have a problem that I cannot understand.
I use a STM32F407 on a Discovery board. I set up channel 1 and channel 2 of the TIM2 timer for input capture. As soon the execution jumps into the interrupt handler "HAL_TIM_IC_CaptureCallback" (and stop on breakpoint at line 3) I can see the right values for SR in the debugger's SFRs window. So, the UIF-flag is set and CC1IF and/or CC1IF. If I do now one step further from the breakpoint, the CCxIF-flags get set to 0. The datasheet says that those got reset by query the CCRx-value but I don't do this:
void HAL_TIM_IC_CaptureCallback(TIM_HandleTypeDef *htim)
{
uint8_t t_status = 0;
if(TIM2->SR & TIM_SR_CC1IF)
t_status = 1;
else if (TIM2->SR & TIM_SR_CC2IF)
t_status = 2;Is it not possible to read the registers in an interrupt routine?
What is the right way to get the channel that caused the interrupt?
What could it be that i do wrong?
Also when it hits the breakpoint the first time in the interrupt routine the CCRx-value I query is not the same like in the debugger's SFRs window.
BR
Christian
