此刻,我正在尝试配置inpute比较引脚。最终,我们将要计算输入信号等的频率,但是现在我们需要使引脚工作。
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;
}
预分频计时器的运行频率为1kHz,因此我们可以以ms为单位进行测量。
因此,目前我已将输入引脚配置为备用模式,设置输入比较设置并进行了中断处理。
在PA15引脚上放置信号时,此功能无效。
我在做什么错了?