Can't get serial to work

Post here first, or if you can't find a relevant section!
Post Reply
Bacab
Posts: 3
Joined: Wed Jun 24, 2020 7:40 pm

Can't get serial to work

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

Re: Can't get serial to work

Post 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.
Bacab
Posts: 3
Joined: Wed Jun 24, 2020 7:40 pm

Re: Can't get serial to work

Post by Bacab »

Thank you for you answer.
I removed the CDC option, switched to "nothing", re-compile however the issue remains.
ejdereldek
Posts: 2
Joined: Thu Nov 18, 2021 4:36 pm

Re: Can't get serial to work

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

Re: Can't get serial to work

Post 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,...?
hobbya
Posts: 49
Joined: Thu Dec 19, 2019 3:27 pm
Answers: 1

Re: Can't get serial to work

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

Re: Can't get serial to work

Post 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.
ejdereldek
Posts: 2
Joined: Thu Nov 18, 2021 4:36 pm

Re: Can't get serial to work

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

Re: Can't get serial to work

Post by fpiSTM »

while(!Serial); is useful for USB CDC.
Post Reply

Return to “General discussion”