STM32F103C6 Serial device issues (reading)

Post here first, or if you can't find a relevant section!
Post Reply
JetSetIlly
Posts: 3
Joined: Mon Oct 16, 2023 2:02 pm

STM32F103C6 Serial device issues (reading)

Post 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
User avatar
fpiSTM
Posts: 1723
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: STM32F103C6 Serial device issues (reading)

Post by fpiSTM »

Which core you used?
JetSetIlly
Posts: 3
Joined: Mon Oct 16, 2023 2:02 pm

Re: STM32F103C6 Serial device issues (reading)

Post 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)
JetSetIlly
Posts: 3
Joined: Mon Oct 16, 2023 2:02 pm

Re: STM32F103C6 Serial device issues (reading)

Post 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.
Post Reply

Return to “General discussion”