Page 1 of 1

Can't get serial to work

Posted: Fri Jun 26, 2020 6:11 pm
by Bacab
Hi everyone,

I feel very dumb for having such a basic issue yet I could not find a solution and I resorted to ask. I can't get my board to print anything on the serial terminal of the Arduino IDE. As far as I can tell everything is setup correctly : I can upload a blinking led code to the board and have it blinked its led, yet for some reason I can't get the serial.print command to work. No error during compilation or upload, there is just nothing printed.

The code I'm trying is the following :

Code: Select all

void setup() {
  // put your setup code here, to run once:
    Serial.begin(115200);
    pinMode(D13, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println("Coucou");
  digitalWrite(D13, HIGH);
  delay(500);
  digitalWrite(D13, LOW);
  delay(500);
}
The code does not hang on the serial.print, it goes on and the led blinks.

I'm using the Arduino IDE (1.8.13) to program a Nucleo 64 STM32L053R8 on a windows 8.1 computer. I'm using the the STM32Core in its 1.9.0 version.

I'm using those settings :
card type : nucleo 64
board part number : Nucleo L053R8
USART support : enabled (generic serial)
USB support : CDC (generic serial supersede USART)
USB speed : Low/full
Optimize : smallest (OS default)
C runtime library : "Newlib nano (default)"
Upload method : mass storage


Thank you in advance for your help.

Re: Can't get serial to work

Posted: Fri Jun 26, 2020 6:55 pm
by fpiSTM
There is no CDC on this board. Remove the usb cdc option. This is a Real uart connected to the stlink which provide a CDC.

Re: Can't get serial to work

Posted: Fri Jun 26, 2020 7:04 pm
by Bacab
Thank you for you answer.
I removed the CDC option, switched to "nothing", re-compile however the issue remains.

Re: Can't get serial to work

Posted: Thu Nov 18, 2021 4:39 pm
by ejdereldek
It is an old topic but exact same issue here. on nucleo 144 and nucleo 32 boards i cant get anyting on screen when i use arduino ide. I already follow above recommendations but no luck. any help highly appreciated.

Re: Can't get serial to work

Posted: Thu Nov 18, 2021 5:32 pm
by fpiSTM
ejdereldek wrote: Thu Nov 18, 2021 4:39 pm It is an old topic but exact same issue here. on nucleo 144 and nucleo 32 boards i cant get anyting on screen when i use arduino ide. I already follow above recommendations but no luck. any help highly appreciated.
Hard to help with those information.
Could you be more precise? Board, option, core version,...?

Re: Can't get serial to work

Posted: Fri Nov 19, 2021 3:50 am
by hobbya
By default Nucleo 64 STM32L053R8 has Serial2 connected to on-board STLink.
So you need to change your code from Serial to Serial2 and connect your PC to the STLink USB port.

If you want to use Serial1 you need to add below and connect the port to PC via a USB-Serial converter:

Code: Select all

HardwareSerial Serial1(PA10, PA9);
void setup()

Re: Can't get serial to work

Posted: Fri Nov 19, 2021 9:03 am
by fpiSTM
hobbya wrote: Fri Nov 19, 2021 3:50 am By default Nucleo 64 STM32L053R8 has Serial2 connected to on-board STLink.
So you need to change your code from Serial to Serial2 and connect your PC to the STLink USB port.
@hobbya yes the STlink is connected to Serial2 so Serial is mapped on it.
No need to change Serial to Serial2 as it is the same instance.

Re: Can't get serial to work

Posted: Tue Nov 23, 2021 1:51 pm
by ejdereldek
fpiSTM wrote: Thu Nov 18, 2021 5:32 pm
ejdereldek wrote: Thu Nov 18, 2021 4:39 pm It is an old topic but exact same issue here. on nucleo 144 and nucleo 32 boards i cant get anyting on screen when i use arduino ide. I already follow above recommendations but no luck. any help highly appreciated.
Hard to help with those information.
Could you be more precise? Board, option, core version,...?
nucleo 144 - f767ZI
nucleo 32 - g431kb

i found the solution in another topic. After Serial.begin(); just add while (!Serial); it worked for me. thanks for support.

Re: Can't get serial to work

Posted: Tue Nov 23, 2021 3:24 pm
by fpiSTM
while(!Serial); is useful for USB CDC.