Page 1 of 1

USART on STM32F411 BlackPill

Posted: Fri Jul 31, 2020 8:46 pm
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

Re: USART on STM32F411 BlackPill

Posted: Sat Aug 01, 2020 7:19 am
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

Re: USART on STM32F411 BlackPill

Posted: Sat Aug 01, 2020 10:16 am
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.
PA12/12 are USB pins.

Re: USART on STM32F411 BlackPill

Posted: Sat Aug 01, 2020 3:00 pm
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?