GPIO Hal remap
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-12-22 5:14 AM
Hi. I'm trying to remap a gpio pin from out to it but the following lines of code don't work.
Can someone help me?
I need to remap GPIOx, GPIO_Pin from out to in on the fly.
void DigitalInOut::SwitchToInput() {
HAL_GPIO_DeInit(GPIOx, GPIO_Pin); GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.Pin = GPIO_Pin; GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOx, &GPIO_InitStruct);}void DigitalInOut::SwitchToOutput() {
HAL_GPIO_DeInit(GPIOx, GPIO_Pin); GPIO_InitTypeDef GPIO_InitStruct; GPIO_InitStruct.Pin = GPIO_Pin; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(GPIOx, &GPIO_InitStruct);}- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-12-23 2:56 AM
Hi Denis,
Your issue is not clear. Could you please give more details: What STM32 product are you using? what do you want to do exactly? where have you found an issue?
Regards,
Khouloud.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-12-23 3:42 AM
Using CubeMX (hal) I have defined a pin as digital output to manage a lcd 2x16 display. OI need to convert it to digital input and then to digital output again. Is there a way? Can someone share an example?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-12-23 6:32 AM
Hello Denis, at the first sight your code should work. The one thing which I would recommend to check is that clock for the corresponding GPIO port is enabled. You can do it in debug session by checking the RCC registers. You can check there also the GPIO registers (for instance GPIOx_MODER for mode).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2016-12-23 3:14 PM
How do you know that that code does not work?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-01-03 12:23 AM
Solved by increasing the stack size.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2017-01-03 4:22 AM
Hi Denis,
Glad that your issue is solved
And thanks for sharing the solution, this may be helpful for other users.Khouloud.
