cancel
Showing results for 
Search instead for 
Did you mean: 

How can I dynamically change the GPIO configuration of stm32f072

dyahn11
Associate II
Posted on August 02, 2017 at 06:10

Hi.

I wonder if I can dynamically change the GPIO configuration of stm32f072.(that is, input to output or output to input)  

Regards.

1 ACCEPTED SOLUTION

Accepted Solutions
Posted on August 02, 2017 at 07:17

Hello!

Yes you can change on the fly the mode of GPIO pin.

by change GPIOx_MODER register.

You can use SPL  function, GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)

HAL function, HAL_GPIO_Init(GPIO_TypeDef  *GPIOx, GPIO_InitTypeDef *GPIO_Init)

Directly,  GPIOx->MODER &= ~ y ;   GPIOx->MODER  |=z;  (zeroize first  and write after) Read Ref MAnual about MODER Reg

View solution in original post

2 REPLIES 2
Posted on August 02, 2017 at 07:17

Hello!

Yes you can change on the fly the mode of GPIO pin.

by change GPIOx_MODER register.

You can use SPL  function, GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)

HAL function, HAL_GPIO_Init(GPIO_TypeDef  *GPIOx, GPIO_InitTypeDef *GPIO_Init)

Directly,  GPIOx->MODER &= ~ y ;   GPIOx->MODER  |=z;  (zeroize first  and write after) Read Ref MAnual about MODER Reg

Posted on August 02, 2017 at 07:23

Thank you very much.