Usb driver for stm32

All the time i connect a board STM32F103C8 Generic to usb I have this message:

USB DEVICE NOT DETECTED DEVICE DESCRIPTOR NOT BRECOGNIZED

I have replaced cable, ports, board, PC with no result. The soft is two line just to test

 #include <Arduino.h>

void setup() {
  Serial.begin(9600);
  Serial.println("Hello, STM32!");
  delay(100);
}

void loop(){
  Serial.println("Looping...");
  delay(100);
  Serial.println("Looping  2 ");
  delay(500);
} 
[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = arduino
upload_protocol = stlink
debug_tool = stlink
monitor_speed = 9600

It is some time I am using these board but up to now I was not in the need to use serial monitor. For sure is a problem of USB drivers for Win11, STlink is working with no problem.

You’re not activating the USB stack. Serial will go out via UART.

Please follow the documentation

[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = arduino
upload_protocol = stlink
debug_tool = stlink
monitor_speed = 9600
build_flags = 
  -DPIO_FRAMEWORK_ARDUINO_ENABLE_CDC

At first thank. Ok the problem seem to be solved but it comes out a conflict with “Wire”, this is my feeling.


#include <Arduino.h>
#include <Wire.h>

int16_t gyro_x, gyro_y, gyro_z;

void setup() {
  Serial.begin(9600);
  Wire.setClock(400000);  // Set I2C frequency to 400kHz
  Wire.begin();
  delay(250);

  Wire.beginTransmission(0x68); // I2C address of MPU6050
  Wire.write(0x6B); // PWR_MGMT_1 register
  Wire.write(0);    // Set to zero (wakes up the MPU-6050
  Wire.endTransmission(true);
}

void loop() {
Wire.beginTransmission(0x68);
Wire.write(0x43); // Starting register for Gyro Readings  
Wire.endTransmission();
Wire.requestFrom(0x68, 6, true); // Request 6 bytes from MPU6050

gyro_x = Wire.read() << 8 | Wire.read();
gyro_y = Wire.read() << 8 | Wire.read();
gyro_z = Wire.read() << 8 | Wire.read();


Serial.print("Gyro X= "); 
Serial.print(gyro_x);
Serial.print(" Gyro Y= "); 
Serial.print(gyro_y);
Serial.print(" Gyro Z= "); 
Serial.println(gyro_z);
delay(250);

}
[env:genericSTM32F103C8]
platform = ststm32
board = genericSTM32F103C8
framework = arduino
upload_protocol = stlink
debug_tool = stlink
monitor_speed = 9600
build_flags = -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC


With this is not working t

What? The USB serial does not interfere with the I2C.

Your code compiles fine, if you want to get rid of the warning, use

Wire.requestFrom((uint8_t) 0x68, (size_t) 6, true); // Request 6 bytes from MPU6050

instead of

Wire.requestFrom(0x68, 6, true); // Request 6 bytes from MPU6050

The default I2C pins are SDA = PB7 and SCL = PB6.

USB D+ and D- are on PA12 and PA11.

If you are unsure whether the I2C device is detected at all, run the I2C Scanner sketch.

thank solved
I got of rid of warnings, very good, but the bug hunging someware the cpu was

Wire.setClock(400000);
Wire,begin();

instead of

Wire.begin(); Wire.setClock(400000);