cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to change modes on GPIO pin from input w/EXTI to timer capture. It appears to change modes, but will not capture timer. Any advice?

CAnde.1
Associate

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.

1 REPLY 1

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