cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CubeMX GPIO Defined initial level after initialization

rm2399
Associate III
Posted on August 11, 2014 at 14:27

To avoid

glitches

at the output

,

we

initialize

in

the following order

:

1. GPIOx

clock

enable

2. Set output

registers

to

defined value

3. Perform

initialization

Now we would

like to use

STM32CubeMX

.

Is it

possible

when initializing the

GPIO

to initialize the

output level

?

Example of

implementation:

0690X00000605fDQAQ.png

In source:

  /*Configure GPIO pins : PE2 PE3 PE4 PE5

                           PE6 PE8 PE9 PE10

                           PE11 PE12 PE14 PE15

                           PE0 PE1 */

  HAL_GPIO_WritePin(GPIOE,GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5

                          |GPIO_PIN_6|GPIO_PIN_8,GPIO_PIN_RESET);

  HAL_GPIO_WritePin(GPIOE,GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10

                          |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_14|GPIO_PIN_15

                          |GPIO_PIN_0|GPIO_PIN_1,GPIO_PIN_SET);

  GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5

                          |GPIO_PIN_6|GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10

                          |GPIO_PIN_11|GPIO_PIN_12|GPIO_PIN_14|GPIO_PIN_15

                          |GPIO_PIN_0|GPIO_PIN_1;

  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

  GPIO_InitStruct.Pull = GPIO_NOPULL;

  GPIO_InitStruct.Speed = GPIO_SPEED_LOW;

  HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);

#initializing #stm32cubemx #gpio
2 REPLIES 2
stm32cube-t
Senior III
Posted on August 29, 2014 at 11:09

Hello,

STM32CubeMX manages the GPIO initialization settings only. The GPIO level is not part of the GPIO init structure (from HAL GPIO driver).

The following need to be used to set the GPIO level:

/**

  * @brief  GPIO Bit SET and Bit RESET enumeration

  */

typedef enum

{

  GPIO_PIN_RESET = 0,

  GPIO_PIN_SET

}GPIO_PinState;

#define IS_GPIO_PIN_ACTION(ACTION) (((ACTION) == GPIO_PIN_RESET) || ((ACTION) == GPIO_PIN_SET))

I have logged a ticket for your request (on STM32CubeMX and requesting the possibility to go beyond the basic GPIO initialization).

Best Regards

stm32cube-t
Senior III
Posted on February 09, 2016 at 12:21

Dear user,

Please note your request is now implemented in STM32CubeMX 4.13.

Thank you