As the title says, I am using an STM32F072BDISCOVERY board and I am trying to implement input capture using timer 3. My input is a PWM signal with a 10% duty cycle, frequency = ~50Hz on port A pin 6. I am trying to generate an interrupt on both rising and falling edges, as well as an interrupt on counter reset (upcounting), I am clocking the counter with a period of 1us. I am only using CMSIS register definitions, no other HALs.
I configure clocks as follows:
RCC->APB1ENR |= RCC_APB1ENR_TIM3EN;
RCC->AHBENR |= RCC_AHBENR_GPIOAEN;
I configure GPIO as follows:
GPIOA->MODER = (GPIOA->MODER & (~(GPIO_MODER_MODER6))) | GPIO_MODER_MODER6_1;
GPIOA->AFR |= 0x1000000;
I configure TIM3 as follows:
TIM3->CCMR1 |= TIM_CCMR1_CC1S_0;
TIM3->CCER |= TIM_CCER_CC1E | TIM_CCER_CC1P | TIM_CCER_CC1NP;
TIM3->DIER |= TIM_DIER_CC1IE | TIM_DIER_UIE;
TIM3->PSC = 0x7;
TIM3->ARR = 0x61A7;
TIM3->CR1 |= TIM_CR1_CEN;
Using the Peripherals System Viewer of Keil UV5 in debug mode, I can tell that all of the configuration bits are correctly set.
In my ISR I check the TIM->3 SR register for the UIF and CC1F flags, and toggle a different LED depending on what flag is set, then clear the flag. The UIF flag LED is the only LED that is toggled. Can anyone see why I am not getting an interrupt on the input capture channel?