2024-09-23 07:42 PM - last edited on 2024-09-24 07:15 AM by SofLit
Hi,
I set it to GPIO Input mode and am using it.
When I receive any signal during MCU operation, I want to convert it to Input -> EXTI mode.
I wrote these codes at the moment, but there seems to be a problem.
My Init code :
GPIO_InitStruct.Pin = ADC_START_SIGNAL_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(ADC_START_SIGNAL_GPIO_Port, &GPIO_InitStruct);
How should I do it?
Thank you.
2024-09-23 11:21 PM
Hi,
I don't use HAL for pin configuration, because it adds too much complexity.
You will most likely find that HAL cannot re-configure a pin (that is - remove a previous configuration first). Find a function that puts the pin back to its 'reset' state first...
Kind regards
Pedro
2024-09-24 06:28 AM
That is how you do it. The interrupts also need to be enabled with the relevant handling code inside of them. Perhaps configure the pin as EXTI and auto-generate the code to see what is needed, and then replicate that.
It would be easier to configure it as EXTI at startup, and reconfigure to input. That way you would have the EXTI infrastructure in place. You could also leave it as EXTI and just disable the interrupt, since the pin is still an input.