Multiple UART1 pins?

Post here first, or if you can't find a relevant section!
Post Reply
Istria
Posts: 2
Joined: Sun Jun 05, 2022 8:39 pm

Multiple UART1 pins?

Post by Istria »

Hello all,

I recently ordered a couple of STM32F103C6T6. This is my first project with the STM32. I have been using Arduino and ESP8266 until now.

While creating my schematic, I noticed there are 3 pins labeled as RXD1: https://www.mischianti.org/wp-content/u ... lution.png

So how does this worm? I assume TX1 and RX1 are used for USB serial. Does that mean I can't use any of the 3 pins labeled RX1? Or can I use 2 out of 3 for general io?

Thanks in advance!
dannyf
Posts: 447
Joined: Sat Jul 04, 2020 7:46 pm

Re: Multiple UART1 pins?

Post by dannyf »

read under AFIO in the datasheet.

Basically some of the peripherals pins show up on physical pins by default, or through remapping (either partial or full). Thus what you see.
Istria
Posts: 2
Joined: Sun Jun 05, 2022 8:39 pm

Re: Multiple UART1 pins?

Post by Istria »

Thanks. I found in the datasheet that PA9 and PA10 TX1 and RX1 fall under "alternate function" and PB6 and PB7 fall under "remapped".

I don't understand the difference completely, but can I assume that normally, PA9 and PA10 will be used for serial and PB6 and PB7 are free to use as gpio? Unless I specify (remap?) the PB6 and PB7 pins, then it's the other way around?

PS. Apparently there is a typo in the pinout I attached. PB6 is TX1 according to the datasheet. Not RX1.
mrburnette
Posts: 633
Joined: Thu Dec 19, 2019 1:23 am
Answers: 7

Re: Multiple UART1 pins?

Post by mrburnette »

I don't understand the difference completely,
Most common microcontrollers have more capabilities than can be utilized at one time because the physical standard sizes limit the number of physical pins. Chip architects and engineer decide how the default "pins" will be configured. Internal switching then manages how defaults can be overridden.
Pinouts.jpg
Pinouts.jpg (61.45 KiB) Viewed 2041 times
Attachments
Pinouts.jpg
Pinouts.jpg (61.45 KiB) Viewed 2041 times
ag123
Posts: 1655
Joined: Thu Dec 19, 2019 5:30 am
Answers: 24

Re: Multiple UART1 pins?

Post by ag123 »

Istria wrote: Sun Jun 05, 2022 10:06 pm Thanks. I found in the datasheet that PA9 and PA10 TX1 and RX1 fall under "alternate function" and PB6 and PB7 fall under "remapped".

I don't understand the difference completely, but can I assume that normally, PA9 and PA10 will be used for serial and PB6 and PB7 are free to use as gpio? Unless I specify (remap?) the PB6 and PB7 pins, then it's the other way around?

PS. Apparently there is a typo in the pinout I attached. PB6 is TX1 according to the datasheet. Not RX1.
To make life simplier, just consider the "alternate functions", you can either *configure* them as gpio or alternate function but not both at the same time.
if in the special case that you used an alternate function at a set of pins, but you still need the other alternate functions at the same pin, then take a look at remapped to see if you can still have them (the alternate function). more often, you could find the same alternate functions at other pins instead of using remapped.
on stm32, pretty much 'all' pins can be configured as gpio, except for a some that can't. functions such as uart is at the pins documented as 'alternate functions' and only if you configure them.

to use an alternate function e.g. uart. there are 2 sets of tasks
1) enable and configure that alternate function
2) configure the pins and select alternate function instead of gpio

miss out one any 1 of the steps and you won't see the alternate function at the pin. it will generally just be gpio.
this includes even things like adc which is an alternate function. most of these are 'hidden' away in the *dunio api and you configure that pin using

Code: Select all

pinMode(pin, MODE_SELECT_PARAM);
Post Reply

Return to “General discussion”