STM32 print statement doesn't work

Hi, I am using an STM32F407G-DISC1 board. I can successfully toggle the I/O pins (set them high and low) using my code, but when I try to print any statements, nothing appears on the serial monitor. I am using a USB type A to Mini-B cable to upload my code. I am using de same baud rate and i am using the correct COM port. Could someone please help me with this?

This my code its a led fading with print staments:


And this my board settings:

And this my output:

Please do not post pictures of code

Please post your sketch, using code tags when you do
Posting your code using code tags prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination

In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.

#define LED_PIN PD12       // the PWM pin the LED is attached to

int brightness = 0;        // how bright the LED is
int fadeAmount = 5;        // how many points to fade the LED by

void setup() {
  Serial.begin(9600);

  pinMode(LED_PIN, OUTPUT);

  Serial.println("Setup complete! LED fading begins.");
}

void loop() {
  analogWrite(LED_PIN, brightness);

  Serial.print("LED Brightness: ");
  Serial.println(brightness);

  brightness = brightness + fadeAmount;

  if (brightness <= 0 || brightness >= 255) {
    fadeAmount = -fadeAmount;
  }
  delay(30);
}

Thank you

Did you open serial monitor? What you showed is the output window where the compile/upload results show.

Hi, my serial monitor is not displaying any messages. Here is a screenshot of my serial monitor while the code is running.

I'm not familiar with your board so can't help further; sorry.

np thank you for responding.

2 Likes

This worked for me.

USBSerial serial;

void setup() {
  serial.begin(115200);
}

void loop() {
  serial.println("Hello");
  delay(200);
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.