STM32C031C6 Timer Input Capture
I'm attempting to do a simple Input Capture using Timer1. I thought as a start I would generate a single 200uS pulse using a Signal Generator and use Timer1 to detect it. I can't seem to get the capture to work no matter what I do.
I tried using HAL and examples from Web...No luck.
I tried examples from a book I have and from the Reference Manual...No luck.
Here is the code I'm currently using;
// TIM1 clock enable
RCC->APBENR2 |= (1 << 11);
// Configure PA8 as alt func TIM1 CH1
RCC->IOPENR = 1;
GPIOA->MODER &= ~(3 << 16);
GPIOA->MODER |= (2 << 16);
GPIOA->AFR[1] &= ~(0x0f);
GPIOA->AFR[1] |= 2;
// TI1 as input
TIM1->CCMR1 |= 0x41;
TIM1->SMCR |= (5 << 4) | 4;
// CC1E Enable output
TIM1->CCER |= 0x0b;
TIM1->CR1 |= 1;
while (1)
{
while(!(TIM1->SR & TIM_SR_CC1IF)){}
// Reset the Update Interrupt Flag
TIM1->SR &= ~TIM_SR_UIF;
}