Description
Example from here doesn't compile in Arduino IDE 1.8.19
and on BlackPill stm32f401ccu6
// RX TX
HardwareSerial Serial1(PA10, PA9);
void setup() {
Serial1.begin(115200);
}
void loop() {
Serial1.println("Hello World!");
delay(1000);
}
c:/users/admin/appdata/local/arduino15/packages/stmicroelectronics/tools/xpack-arm-none-eabi-gcc/12.2.1-1.2/bin/../lib/gcc/arm-none-eabi/12.2.1/../../../../arm-none-eabi/bin/ld.exe: C:\Users\admin\AppData\Local\Temp\arduino_cache_150181\core\core_a9c0fc81ed87578aed206a502d28436a.a(HardwareSerial.cpp.o):(.bss.Serial1+0x0): multiple definition of `Serial1'; sketch\Test.ino.cpp.o:(.bss.Serial1+0x0): first defined here
collect2.exe: error: ld returned 1 exit status
exit status 1
Related link.
This code work awesome
void setup() {
Serial.begin(115200);
}
void loop() {
Serial.println("Hello, Serial port!");
delay(1000);
}
And this one
void setup() {
Serial1.begin(115200);
}
void loop() {
Serial1.println("Hello, Serial port!");
delay(1000);
}
If compile code
// RX TX
HardwareSerial Serial2(PB7, PB6);
void setup() {
Serial.begin(115200);
Serial2.begin(115200);
}
void loop() {
Serial2.println("Data received from Serial 2");
delay(200);
Serial.println("Data received from Serial");
delay(200);
}
I get output on PA9
And that's where it all ends...
And on PB6
exactly the same conclusion
Green - Serial on PA9
Yellow - Serial2 on PB6
Serial ports through HardwareSerial
do not work adequately.