Hi. I have a question for you. I am using stm32l0. In order to power a module, I must use the same pin of the microprocessor as both input and output. What functions can I do this?
I wish you a good day
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-09 6:38 AM
Do this with Arduino"
#define OutputSDIO() pinMode(SDIO,OUTPUT)
#define InputSDIO() pinMode(SDIO,INPUT)" functions. What functions can I do this using stm32cubeide?
- Labels:
-
STM32L0 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-09 6:54 AM
If you need to read state of an (open collector) pin set to output, just set the pin as output, its input level can be read regardless of that.
If you need to switch between input and output dynamically, change the given pin's setting in GPIO_MODER, read the GPIO chapter in RM.
I don't use Cube/HAL.
JW
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-09 1:26 PM
HAL_GPIO_Init can be used to initialize pins in input or output mode. STM32CubeMX will generate example initialization code for you.
For example, this initializes PA0 in input mode:
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = GPIO_PIN_0;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-09 11:21 PM
Hi. first of all thank you very much. How can I fix this error?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2021-12-09 11:27 PM
Create the variable you are using. You could do so locally within the subroutine.​
Up vote any posts that you find helpful, it shows what's working..
