USART on STM32F411 BlackPill

Post Reply
konczakp
Posts: 6
Joined: Sat Jul 25, 2020 8:22 pm

USART on STM32F411 BlackPill

Post by konczakp »

Hi,

Could someone explain me why on earth on the board diagram of the blackpill there are three USART1 ports (rx1 on pins PA10,PB3,PB7 ant tx1 on pins PA9,PA15,PB6). I was able to run USART1 on PB6 and PB7, USART2 on PA3 and PA2 and the USB-C is on the PA11 and PA12. Are the other USART1 pins some how usable as separate rx-tx ports. If Yes than How? If not then why they are there. Usually if some pins are multi usage (like USART and I2C etc) then they are usable but in this case I was not able to get the other USART1 to run.

Thanks
GonzoG
Posts: 113
Joined: Wed Jan 15, 2020 11:30 am
Answers: 8

Re: USART on STM32F411 BlackPill

Post by GonzoG »

Those are alternate pins.
PA9 and PA10 are used with USB,
PB6 and PB7 are used with I2C1
so if you cannot use them you have 3rd pair: PA15 and PB3 but you need to change pin assignment:
https://github.com/stm32duino/wiki/wiki ... wareserial
stevestrong
Posts: 476
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: USART on STM32F411 BlackPill

Post by stevestrong »

Which block diagram do you refer to?
How did you manage to use USART1 on PB6/7?
Please always post links/code, otherwise we cannot read your thoughts.
PA9/10 are usually TX1, RX1.
PA11/12 are USB pins.
Last edited by stevestrong on Fri Apr 02, 2021 3:52 pm, edited 1 time in total.
konczakp
Posts: 6
Joined: Sat Jul 25, 2020 8:22 pm

Re: USART on STM32F411 BlackPill

Post by konczakp »

Thanks GonzoG for the link. I omitted this info somehow ... But thanks to this I was able to redirect USART1 to different pins. At the begining I was doing this wrong.
SteveStrong You are right, thanks for the correction. I've made a mistake in first post putting wrong pin names.
Now HW Serial is working as in here:

Code: Select all

HardwareSerial Serial2(USART2);

#include <SoftwareSerial.h>

SoftwareSerial mySerial(PB1, PB0); // RX, TX

void setup() {
  Serial1.setRx(PB7);
  Serial1.setTx(PB6);
  Serial1.begin(115200);
  Serial2.begin(115200);
  mySerial.begin(9600);
  
  
}

void loop() {
  Serial1.println("hello 1");
  Serial2.println("hello 2");
  mySerial.println("hello 3");
  delay(1000);
}

I was referring to this diagram
https://miro.medium.com/max/3122/1*ixFS ... 0w6jFA.png

Unfortunately I'm still having problems with getting the SoftwareSerial running. It is also in the code above and it is not sending any data. Someone else has similar problem so I wrote also in other thread but still nothing. Can You guys help me with this also?
elliotP890
Posts: 1
Joined: Fri Apr 02, 2021 12:01 pm

Re: USART on STM32F411 BlackPill

Post by elliotP890 »

Hey guys,

I'm in the same position as the original post, and I'm having difficulty understanding the replying posts. I need to use 2 serial ports for a drone project on my STM32F411 board. One is for my reciever (just an Rx pin), and one for a GPS module. Using the same pinout diagram that's been posted here already: https://miro.medium.com/max/3122/1*ixFS ... 0w6jFA.png

I don't understand why there are multiple serial1 ports and if its possible to use 2 different serial ports. I'm also using the usb occasionally to use the serial monitor in Arduino. Are the multiple serial1 ports simply just different pins to redirect USART1 or can I using them as separate serial connections?
Also why is there Tx6 and Rx6 (A11 and A12) on the board? Really struggling to understand this, my understanding was that different serial ports were labelled Tx/Rx and numbered accordingly. Can someone help me understand this?

Thanks,
Elliot
ag123
Posts: 800
Joined: Thu Dec 19, 2019 5:30 am
Answers: 4

Re: USART on STM32F411 BlackPill

Post by ag123 »

normally uart1 is on pa9, pa10
uart2 is on pa2, pa3

other things are check in the core files if they are declared that way, or if you are declaring it manually you may need to specify the pns
https://github.com/stm32duino/wiki/wiki ... wareserial

then some functions can be remapped to other pins, but if you are able to use the default pins above, they could be 'easier'
Post Reply

Return to “STM32F4 based boards”