Page 1 of 1

STM32F103C6 Serial device issues (reading)

Posted: Mon Oct 16, 2023 2:27 pm
by JetSetIlly
Hello,

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've tried different USB cables and I'm certain the permissions for the device are correct (I am using a Linux operating system).

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

Re: STM32F103C6 Serial device issues (reading)

Posted: Mon Oct 16, 2023 3:06 pm
by fpiSTM
Which core you used?

Re: STM32F103C6 Serial device issues (reading)

Posted: Mon Oct 16, 2023 3:20 pm
by JetSetIlly
Thank you for replying.

I am using the core from this URL:

https://github.com/stm32duino/BoardMana ... index.json

The settings in the Arduino IDE are as follows:

Board: Generic STM32F1 series
Board part number: BluePill F103C6 (32k)
U(S)ART support: Enabled (generic 'Serial')
USB support: CDC (generic Serial supersede U(S)ART
USB speed: Low/Full Speed
C Runtime Library: Newlib Nano (default)

Re: STM32F103C6 Serial device issues (reading)

Posted: Mon Oct 16, 2023 6:25 pm
by JetSetIlly
I've tried input/output with a TTL module attached to hardware pins 10 and 11 and that works.

It would be great to hear any ideas into what might be happening with the USB port but at least I can proceed with my project for now.