STM32F4 - How do I switch a pin from ADC to normal GPIO mode?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-31 08:12 AM
Greetings all,
I'm using the HAL libs to set a couple of pins for ADC use (one-shot).
Later on during fw execution, i need to flip some of these pins back to normal GPIO mode.
How do I do this?
I've been looking over the programming manual, and HAL/LL library source for a few hours now, and haven't been able to see anything that will let me do so.
Thanks in advance.
- Labels:
-
ADC
-
GPIO-EXTI
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-31 08:21 AM
The HAL_GPIO_Init function is used to initialize/reinitialize pins.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2020-03-31 09:05 AM
Hello,
You can change the mode state of the GPIO in GPIOx_MODER register in section "8.4.1 GPIO port mode register (GPIOx_MODER) (x = A..I/J/K)".
Also you can use the GPIO_InitTypeDef, this is a GPIO Initialization structure definition contain all the needed details of each GPIO Pin.
this is an example on how use this structure :
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; // Specifies the operating mode for the selected pin
GPIO_InitStruct.Pull = GPIO_PULLUP;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Pin = GPIO_PIN_1;//Specifies the GPIO pins to be configured
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); //Initializes the GPIOA peripheral according to the specified parameters in the HAL_GPIO_Init
Best Regards,
Mohamed Aymen.