STM32F411CE Black Pill Serial Port Pin Mapping

Hello,
I am just trying out the new IDE ver 2 Beta 11 with a Black Pill STM32F411CE and a few examples.
Now i just loaded in the Multiple Serial test example code below and it compiles just fine.
Problem is I don't know how the Arduino Port/Pin mapping works hence no idea off which pins are: Serial TX, Serial RX, Serial1 TX, Serial1 RX..
How do i find this out please?
Many thanks imk

/*

Multiple Serial test

Receives from the main serial port, sends to the others.

Receives from serial port 1, sends to the main serial (Serial 0).

This example works only with boards with more than one serial like Arduino Mega, Due, Zero etc.

The circuit:

  • any serial device attached to Serial port 1

  • Serial Monitor open on Serial port 0

created 30 Dec 2008

modified 20 May 2012

by Tom Igoe & Jed Roach

modified 27 Nov 2015

by Arturo Guadalupi

This example code is in the public domain.

https://www.arduino.cc/en/Tutorial/BuiltInExamples/MultiSerialMega

*/

void setup() {

// initialize both serial ports:

Serial.begin(9600);

Serial1.begin(9600);

}

void loop() {

// read from port 1, send to port 0:

if (Serial1.available()) {

int inByte = Serial1.read();

Serial.write(inByte);

}

// read from port 0, send to port 1:

if (Serial.available()) {

int inByte = Serial.read();

Serial1.write(inByte);

}

}

Do you mean this board ?

Yes that is the board, i can see multiple pin options for TX1 RX1 which i guess is Serial.
But which of the options, also what about Serial mapping
Sorry i don't know Arduino IDE H includes so no idea what/how is pin mapped?
many thanks imk

I suppose you use the core from roger clark ( your sketch only compiles with this core ). Serial in this case is the USB Serial, that means the serial monitor. Serial1 is TX1/RX1 on pin A9/A10. If you short A9 to A10 you will get back to the serial monitor what you send from it ( through TX1->RX1 ).

Well after a bit of testing and scope'ing it turns out that Serial and Serial1 both map to PA9 and PA10. It seems they are essentially the same port with two software definitions, more reading to do.

Thus if you want SERIAL TWO code as below:
As you can see I haven't tested the Rx yet, that tomorrows project :slight_smile:

HardwareSerial Serial2( PA3 , PA2 );

void setup()
{ // initialize both serial ports:
Serial.begin(9600);
Serial1.begin(9600);
Serial2.begin(9600);
}

void loop()
{
Serial.write( 'A');
delay( 5 );

Serial1.write( 'U' );
delay( 5 );

Serial2.write( "123" );
delay( 5 );
}IMG_5640

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.