USB CDC Serial API for blue pill
Posted: Tue Jul 04, 2023 8:03 am
Hi all, I have flashed a blue-pill with maple boot loader and I am trying to use Serial capability of the bluepill board to read and write characters. My code is as follows:
While I do get "Serial Working" printed on the serial monitor, no matter what I do, I am unable to read the characters sent from my PC in the blue pill. On some debugging, I found that Serial.available() always returns 0 no matter what I send from my PC. Anyone faced similar issues with the Serial library. Enclosing a snippet for core and related information. Any leads are appreciated. Thanks!
Code: Select all
void setup() {
Serial.begin(9600); // Set the baud rate to match your serial monitor
while(!Serial);
Serial.println("Serial Working");
}
void loop() {
if (Serial.available() > 0) {
char receivedChar = Serial.read(); // Read the incoming character
// Print the received character
Serial.print("Received character: ");
Serial.println(receivedChar);
}
delay(10);
}