There is really weird issue that you have to set the (virtual) DTR line now for your to be able to receive data: [CDC] Serial USB without DTR · Issue #1193 · stm32duino/Arduino_Core_STM32 · GitHub
I was able to do this using HTerm - der-hammer and clicking on the “DTR” button in the “input control” section and in PlatformIO per monitor_dtr
.
I was just really struggling with this, too.
Also, some of the flags above are not necessary anymore. Please try the following platformio.ini
:
[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = arduino
build_flags =
; enable Serial2 and 3
-D HAVE_HWSERIAL2
-D HAVE_HWSERIAL3
; enable USB serial
-D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
-D USBCON
; QUIRK: without setting this, no
; data will be received on the serial USB port
; https://github.com/stm32duino/Arduino_Core_STM32/issues/1193
monitor_dtr = 1
; optional: set COM port to monitor here if there are multiple
;monitor_port= COM27
with the following src\main.cpp
#include <Arduino.h>
void setup() {
Serial1.begin(115200);
Serial2.begin(115200);
Serial3.begin(115200);
SerialUSB.begin(115200);
pinMode(PC13, OUTPUT); //blinky
//while(!Serial); //wait for USB connection
}
void loop() {
Serial1.println("Hello from Serial1");
Serial2.println("Hello from Serial2");
Serial3.println("Hello from Serial3");
SerialUSB.println("Hello from SerialUSB");
SerialUSB.flush();
digitalWrite(PC13, digitalRead(PC13) ^ 1); //blinky
delay(500);
}
Then a “upload” and then a “monitor” gives me
> Executing task in folder bluepill_f103c8_128k_repro: C:\Users\Max\AppData\Local\Programs\Python\Python38\Scripts\platformio.exe device monitor --environment genericSTM32F103C8 <
--- Available filters and text transformations: colorize, debug, default, direct, hexlify, log2file, nocontrol, printable, send_on_enter, time
--- More details at http://bit.ly/pio-monitor-filters
--- forcing DTR active
--- Miniterm on COM27 9600,8,N,1 ---
--- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Hello from SerialUSB
Hello from SerialUSB
Hello from SerialUSB
Hello from SerialUSB
Hello from SerialUSB
Hello from SerialUSB
--- exit ---