I cannot get a Timer Capture to work on STM32F7805-DK
I have tried Timer 2 CH1, and Timer 3 CH1. No Luck.
I know the pin has a square wave going into it and the timer is counting, because I can poll GPIOB->IDR and read TIM3->CNT.
Nothing I can do can get a reading other then zero from TIM3->CC1
I cannot get a IRQ from TIM3 unless I force it via TIM3->EGR |= 2;
My Init Code:-
void InitTimer3(void)
{
GPIOB->PUPDR &= ~(3<<8); // No Pullup or Pulldown
GPIOB->OSPEEDR |= (3<<8); // Very High speed
GPIOB->MODER &= ~(3<<8); // PB4 Input
GPIOB->AFR[0] &= ~(0x0F << 16);
GPIOB->AFR[0] |= (2<<16); // AF2
RCC->APB1ENR |= 2; // Timer 3 enable
RCC->AHB1ENR |= 2; // PORTB Clock Enable
TIM3->CCER = 0;
TIM3->PSC = 511; // Prescale
TIM3->ARR = 0xFFFF;//250; // Max Count
TIM3->CCMR1 = 1; // Compare 1
TIM3->DIER = (1<<1) | 1; // CC1 IRQ enabled
TIM3->CR1 = (1<<7) | 1; // Enabled, UP, Auto Reload Buffered
TIM3->CR2 = 0;
TIM3->CCER = (1<<3) | (1<<1) | 1;//1; // Enable Compare 1, Both Edges
TIM3->SR = 0;
NVIC_SetPriority(TIM3_IRQn, 0);
NVIC_EnableIRQ(TIM3_IRQn);
}
My IRQ:-
void TIM3_IRQHandler(void)
{
if ((TIM3->SR & 2) != 0) // Capture 1
{
Dwell ++;
TIM3->SR &= ~2;
}
if ((TIM3->SR & 1) != 0) // OVF WORKS!!!!!!
{
TIM3->SR &= ~1;
}
}
Dwell will not advance, unless I put Dwell ++; into the OVF code
