cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO mode change

giwonKIM
Associate III

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.

2 REPLIES 2
PGump.1
Senior III

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

AI = Artificial Intelligence, NI = No Intelligence, RI = Real Intelligence.
TDK
Guru

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.

If you feel a post has answered your question, please click "Accept as Solution".