problem with stm32 multiple serial port access

hi,
i uploaded the below program which eventhough successfully uploaded to my stm32f103c8 but i am not getting any data in the other port and both the data is displayed on a single port.The only port working is pa9,pa10.none of the other serial ports are working.plz do help me as soon as possible.

include <uart.h>

void setup(){
Serial1.begin(9600);
Serial.begin(9600);
}

void loop(){
Serial1.println(“abc”);
delay(1000);
Serial.println(“def”);
}

I'm using STM32F103C8 bluepill clone
The "core" is Arduino_core_stm32 V 1.4 (not the maple core).
Here is what I use to get 3 UARTs running together:

// refer .../variants/BLUEPILL_F103C8/PeripheralPins.c to see relevant/possible pins
HardwareSerial Serial2(USART2); // or HardWareSerial Serial2 (PA3, PA2);
HardwareSerial Serial3(USART3);

void setup() {
Serial.begin(19200); // on PA9 PA10
Serial2.begin(19200); // on PA3 PA2
Serial3.begin(19200); // on PB11 PB10

Serial.println("Serial: HELL000");
Serial2.println("Serial2: Hell");
Serial3.println("Serial3: Lo !");
}

void loop() {
}

See here: GitHub - BLavery/STM32F103-Arduino: Notes on using Arduino_Core_STM32 with "Bluepill"</t

I'm using STM32F103C8 bluepill too;

but no need to use HardwareSerial;

STM32 has 3 SERIAL port : SERIAL (PA9 PA10) , SERIAL1 (PA3 PA2) , SERIAL2 (PB11 PB10);

It`s my code (work correctly) :

void setup() {
Serial.begin(9600);
Serial1.begin(9600);
Serial2.begin(9600);

}

void loop() {
Serial.println("HELLO");
Serial1.println("HELLO1");
Serial2.println("HELLO2");
delay(1000);
}

Thats not true:

Chip you are talking about has actualy 4 Serial interfaces:

You can enable them like this:

Serial1.begin(9600); //TX-PA9/RX-PA10
Serial2.begin(9600); //TX-PA2/RX-PA3
Serial3.begin(9600); //TX-PB10/RX-PB11
Serial.begin(9600); //USB (PA11/PA12)

Once you begin() USB serial you will get /dev/ttyACM0 port in Linux (sorry im using only Linux)
So everything you are sending to Serial.print() you can catch in USB port. Thats very useful for debug.

@vbondarenko
You're the one that's actually wrong here. Serial interface (or port) in this context refers to UART port.
USB and UART are different protocols. Get that into your skull.
PA11 and PA12 are for USB comm, not UART.

Using PlatformIO with an Arduino framework instead of the actual Arduino IDE, I found that HardwareSerial was needed. The blavery code above worked, and the kaveco code (1) would not compile until I removed references to Serial2 and (2) produced both the Serial and Serial1 outputs on both on PA9 (aka TX1).

I have not tried this using the actual Arduino IDE, but I suspect that that may be the difference.

dammy999:
@vbondarenko
You’re the one that’s actually wrong here. Serial interface (or port) in this context refers to UART port.
USB and UART are different protocols. Get that into your skull.
PA11 and PA12 are for USB comm, not UART.

Yes, but it becomes a Serial port if it is configured as a VCP (virtual comm port) on the USB. You have to remember to select it in Tools when you upload a sketch.