Why doesn't my input compare react to input signals?
Good evening everyone,
At the moment I am trying to configure an inpute compare pin. Eventually we are going to calculate the frequency of the input signal etc etc, but for now we need to get the pin working.
GPIOA->MODER = (GPIOA->MODER & ~GPIO_MODER_MODER15) |(0b10 << GPIO_MODER_MODER15_Pos);
GPIOA->PUPDR = (GPIOA->PUPDR &~GPIO_PUPDR_PUPDR15) | (0b10 << GPIO_PUPDR_PUPDR15_Pos);
RCC->APB1ENR |= RCC_APB1ENR_TIM2EN;
TIM2->PSC = 0.098;
TIM2->ARR = 65535;
TIM2->CCER &= ~TIM_CCER_CC1E;
TIM2->CCMR1 |= TIM_CCMR1_CC1S_0;
TIM2->CCER |= TIM_CCER_CC1P_Msk;
TIM2->CCMR1 |= TIM_CCMR1_IC1PSC;
TIM2->CCER |= TIM_CCER_CC1E;
TIM2->DIER |= TIM_DIER_UIE;
TIM2->DIER |= TIM_DIER_CC1IE;
TIM2->CR1 |= TIM_CR1_CEN;
NVIC_EnableIRQ(TIM2_IRQn);
void TIM2_IRQHandler(void)
{
char *msgStart = "Rising edge\r\n";
HAL_UART_Transmit(&huart2, (uint8_t*)msgStart, strlen(msgStart), HAL_MAX_DELAY);
TIM2->SR &= ~TIM_SR_CC1IF;
}
Where the prescaled timer runs at 1kHz so that we can measure in ms.
So at the moment I have configured an input pin to alternate mode, set the input compare settings and made the interrupt handler.
This doesn't work when put a signal on pin PA15.
What am I doing wrong?
