CubeMX MX_GPIO_Init() Set GPIO output level at runtime before initialization
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-03-29 4:00 AM
Hello,
I want to know if there is a way to set the GPIO output level for an output at runtime before it will be initialized by the CubeMX generated MX_GPIO_Init() function?
In other words: The MX_GPIO_Init() function writes the in CubeMX configured value to a GPIO output before intializing it:
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(***_GPIO_Port, ***_Pin, GPIO_PIN_SET);
Can I somehow get CubeMX to insert a variable name/value instead of the define 'GPIO_PIN_SET' which would allow me to change the value before calling the MX_GPIO_Init() function?
My intention is to decide at runtime if this pin should be initialized to high or low. I could copy&paste the generated MX_GPIO_Init() and adapt it to my needs, but then I am not in sync with the CubeMX project anymore. Also changing the pin value after the initialization is not an option for me because I don't want a wrong value at the pin.
Thanks,
Jens
Edit: Tried to clarify the 'runtime' aspect of the question.
- Labels:
-
GPIO-EXTI
-
STM32CubeMX
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-03-29 4:15 AM
Hello @Jens_ ,
Open STM32CubeMX, Configure and select I / O :
(1).GPIO output level (pin initial level setting)
- The High output is initialized to a High level
- The Low output is initialized to a Low level
(2) . GPIO mode (GPIO output mode)
- Output Push pull output has strong high and low levels, which can supply power to IO equipment
- The Output Open Drain output mode is strong low level. Only low level can supply power to IO equipment, but high level can only be output as a signal
(3) . GPIO pull up / pull down
- No pull up and no pull down
- Pull up internal pull-up resistance
- Pull down internal resistance
(4) . maximum output speed (pin speed setting)
- Low low speed
- Medium medium speed
- High speed
- Very High
(5) . user label
- Set the name of the pin
Hope I helped you!
Foued
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2023-03-29 4:21 AM
Hello Foued,
this looks like the normal workflow with a constant definition. This does not work for me.
I want to decide at runtime before initialization if the pin shall be high or low.
Best Regards,
Jens
