Skip to main content
dyahn11
Associate
August 2, 2017
Solved

How can I dynamically change the GPIO configuration of stm32f072

  • August 2, 2017
  • 1 reply
  • 2033 views
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.

    This topic has been closed for replies.
    Best answer by Vangelis Fortounas
    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

    1 reply

    Vangelis Fortounas
    Associate II
    August 2, 2017
    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

    dyahn11
    dyahn11Author
    Associate
    August 2, 2017
    Posted on August 02, 2017 at 07:23

    Thank you very much.