How to Define 3rd serial port on STM32F411CE BP
Posted: Thu Mar 10, 2022 11:23 pm
Hello,
I am trying to define a third serial port on a STM32F411CE Black Pill and the program never sends on third port and crashes after a second or two.
Hello as can be seen in the code below I am enabling three serial ports and have tried Serial3 & Serial6 for the 3rd port but can't get it to work.
Serial, Serial1 and Serial2 work as expected but I am obviously missing a bit of magic to get the 3rd port working.
Also if the program calls Serial3.println("000"); or Serial6.println("000"); the program will crash after a few seconds and no longer send on Serial1 and Serial2. Any ideas please?
Many thanks in advance imk
#define LED_PIN PC13 // Black Pill
HardwareSerial Serial2( PA3 , PA2 ); // Rx Tx
HardwareSerial Serial3( PB0 , PB1 ); // Rx Tx
//HardwareSerial Serial6( PB0 , PB1 ); // Rx Tx
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
Serial2.begin(9600);
Serial3.begin(9600);
//Serial6.begin(9600);
pinMode(LED_PIN, OUTPUT);
}
void loop()
{
Serial1.println("123"); // Goes to Pin PA9
Serial2.println("ABC"); // Goes to Pin PA2
//Serial3.println("000"); // Goes to Pin
//Serial6.println("000"); // Goes to Pin
digitalWrite(LED_PIN, HIGH);
delay(100);
digitalWrite(LED_PIN, LOW);
delay(100);
}
I am trying to define a third serial port on a STM32F411CE Black Pill and the program never sends on third port and crashes after a second or two.
Hello as can be seen in the code below I am enabling three serial ports and have tried Serial3 & Serial6 for the 3rd port but can't get it to work.
Serial, Serial1 and Serial2 work as expected but I am obviously missing a bit of magic to get the 3rd port working.
Also if the program calls Serial3.println("000"); or Serial6.println("000"); the program will crash after a few seconds and no longer send on Serial1 and Serial2. Any ideas please?
Many thanks in advance imk
#define LED_PIN PC13 // Black Pill
HardwareSerial Serial2( PA3 , PA2 ); // Rx Tx
HardwareSerial Serial3( PB0 , PB1 ); // Rx Tx
//HardwareSerial Serial6( PB0 , PB1 ); // Rx Tx
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
Serial2.begin(9600);
Serial3.begin(9600);
//Serial6.begin(9600);
pinMode(LED_PIN, OUTPUT);
}
void loop()
{
Serial1.println("123"); // Goes to Pin PA9
Serial2.println("ABC"); // Goes to Pin PA2
//Serial3.println("000"); // Goes to Pin
//Serial6.println("000"); // Goes to Pin
digitalWrite(LED_PIN, HIGH);
delay(100);
digitalWrite(LED_PIN, LOW);
delay(100);
}