I am trying to understand a very basic USB communication problem I am having with a STM32F103C6 (bluepill) device.
I am successfully programming it with a ST-Link v2. However, USB communication is not working as expected.
Writing data to the Serial device works and I can see the data transmitted in the Serial Monitor. For example, this very simple program works exactly as expected.
Code: Select all
void setup() {
Serial.begin();
while (!Serial) {}
}
void loop() {
Serial.println(random(100,999));
}
However, receiving data does not work. This simple echo program fails. The if condition in the loop() function never succeeds.
Code: Select all
void setup() {
pinMode(PC13, OUTPUT);
Serial.begin();
while (!Serial) {}
}
void loop() {
if (Serial.available() > 0) {
digitalWrite(PC13, HIGH);
String s = Serial.readString();
Serial.print(s);
}
}
I'm beginning to think it's a hardware issue on the board(s) I have. Or is there a configuration step that I am missing?
Regards