STM32F407 Disc Board : Pin Configuration Function ?

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
nikhiledutech
Posts: 118
Joined: Wed Dec 27, 2017 8:52 am

STM32F407 Disc Board : Pin Configuration Function ?

Post by nikhiledutech » Fri Jan 05, 2018 7:12 am

hey,
So on stm board, i want to read ADC values from "PC6" , but the same pin is defined for "UART6" . Because of it, I am not able to read ADC values.

So is there any configuration function to configure pins, so that i can use pin PC6 for ADC as well.

Thanks

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: STM32F407 Disc Board : Pin Configuration Function ?

Post by dhylands » Fri Jan 05, 2018 2:53 pm

You can read the ADC value regardless of how the pin is configured (at least on the STM32F4 hardware).

If you refer to the reference manual:
http://www.st.com/content/ccc/resource/ ... 031020.pdf
and refer to Figure 25 on page 268, it shows a block diagram of a typical GPIO pin. In the very top left corner you'll see a label "Analog" and in the bottom left you'l see something called "Alternate function output".

You can read the ADC value regardless of how the pin is configured. If the pin is configured as an output function (like USART_TX) the you'll be reading the values of the voltages being transmitted. If the pin is configured as an input, then you'll be reading the values of whatever is connected to the pin. If it was connected to a UART, you can actually read the ADC values of the UART bits coming in.

Post Reply