2020-11-17 02:40 PM
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_7); //PA7 is no longer GPIO interrupt source
Here is my code to go into timer mode:
/*ReConfigure GPIO pin : PtPin */
GPIO_InitStruct.Pin = Vib_In_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF5_TIM22;
HAL_GPIO_Init(Vib_In_GPIO_Port, &GPIO_InitStruct);
// Now it should be timer 22.2 input capture
/* set capture to a falling edge, since rising edge got us here in the first place */
__HAL_TIM_SET_CAPTUREPOLARITY(&htim22, TIM_CHANNEL_2, TIM_INPUTCHANNELPOLARITY_FALLING);
HAL_TIM_IC_Start_IT(&htim22, TIM_CHANNEL_2); //turn on timer 22 chan 2 with IRQ
Timer interrupt never happens.
2020-11-17 03:52 PM
Which STM32?
Set it up as timer capture, then enable EXTI writing directly to EXT/SYSCFG registers (there may be some Cube incantation for that, I don't Cube).
JW
[EDIT] Quick search returned https://community.st.com/s/question/0D50X0000ADB3vsSQD/how-to-enable-external-interrupt but I am sure there are more such here