Skip to main content
dyahn11
Associate
Aug 2, 2017 4:10 AM UTC
Solved

How can I dynamically change the GPIO configuration of stm32f072

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.
    Vangelis Fortounas
    Associate II
    Aug 2, 2017 5:17 AM UTC
    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

    2 replies

    Vangelis Fortounas
    Associate II
    Aug 2, 2017 5:17 AM UTC
    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
    Aug 2, 2017 7:23 AM UTC
    Posted on August 02, 2017 at 07:23

    Thank you very much.