Hi all,
I want to test UART communication on Nucleo64 F303 board and I have a problem.
I send a message with another board to this Nucleo (to Serial 1 and Serial2).
In NUC I want to receive massages in Serial1 and Serial2, nad transfer it to Serial (USB).
such a simple quick test to see if the series are working (and pins are correct).
Unfortunately, only Serial1 works for me and it doesn't read anything from S2.
At the beginning I need to define the pins for Serial1 (without it I get an error when compiling).
If I also define Serial2, there is an error ‘multiple definition of `Serial2';’
What can I do to make this Serial2 work?
HardwareSerial Serial1(PA10, PA9);
//HardwareSerial Serial2(PA3, PA2);
void setup() {
Serial.begin(115200); // USB ST-LINK
Serial1.begin(115200); // PA9 (TX), PA10 (RX)
Serial2.begin(115200); // PA2 (TX), PA3 (RX)
delay(1000);
Serial.println("Start test");
}
void loop() {
if (Serial1.available()) {
String received1 = Serial1.readStringUntil('\n');
Serial.print("Serial1: ");
Serial.println(received1);
}
if (Serial2.available()) {
String received2 = Serial2.readStringUntil('\n');
Serial.print("Serial2: ");
Serial.println(received2);
}
}