Page 1 of 1
[Solved]Cant use Serial.print in setup()
Posted: Fri Jul 09, 2021 12:34 pm
by feel
Hi, i got issues when i try to use Serial.print func in setup(). Here the code i use
Code: Select all
void setup() {
Serial.begin(115200);
Serial.print("Hello, World");
}
void loop() {
}
I use STM32F411CEU6 Board, thank you!
Re: Cant use Serial.print in setup()
Posted: Fri Jul 09, 2021 1:15 pm
by fpiSTM
Well with those information what did you expect ?
Which core?
Which target selected? generic? blackpill?...
Is it Hardware Serial or USB CDC ?
If Serial is the USB CDC then you have to wait after the begin.
https://www.arduino.cc/reference/en/lan ... /ifserial/
Re: Cant use Serial.print in setup()
Posted: Fri Jul 09, 2021 4:07 pm
by feel
i use this settings for my code

- settings.png (16.93 KiB) Viewed 7400 times
Re: Cant use Serial.print in setup()
Posted: Fri Jul 09, 2021 4:42 pm
by ag123
can you describe your issues?
what is the serial terminal/monitor that you are using?
did you try
Serial.print
ln("hello world") instead?
did you manage to blink the led?
have you reviewed these links?
viewtopic.php?f=2&t=3
viewtopic.php?f=2&t=301
Re: Cant use Serial.print in setup()
Posted: Fri Jul 09, 2021 4:51 pm
by fpiSTM
Try this as stated before:
Code: Select all
void setup() {
Serial.begin(115200);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB
}
Serial.print("Hello, World");
}
void loop() {
}
And check that Serial is properly enumerated and you select the right COM port.
Re: Cant use Serial.print in setup()
Posted: Fri Jul 09, 2021 5:10 pm
by ag123
oh and in linux modemmanager can mess with usb-serial, but describe it more as we've no idea what is wrong.
if you are using linux and you suspect modemmanager could be causing it, check the faq in the wiki
https://github.com/stm32duino/wiki/wiki ... itor-fails
Re: Cant use Serial.print in setup()
Posted: Sat Jul 10, 2021 6:35 am
by feel
Thanks it worked! i just try to print something in setup() in my project but i found out its not working.
thank you for the support guys
Re: Cant use Serial.print in setup()
Posted: Sat Jul 10, 2021 7:00 am
by fpiSTM
feel wrote: Sat Jul 10, 2021 6:35 am
Thanks it worked! i just try to print something in setup() in my project but i found out its not working.
thank you for the support guys
Fine. The while was the solution?
Re: Cant use Serial.print in setup()
Posted: Sat Jul 10, 2021 8:11 am
by feel
Yeah the while was the solution, im still new to use this stm32duino so i'd need to learn much things