[solved] STM32L476RG Serial Messup

All about boards manufactured by ST
Post Reply
paulportohernan
Posts: 10
Joined: Sun Dec 20, 2020 4:32 pm
Answers: 1

[solved] STM32L476RG Serial Messup

Post by paulportohernan »

i just got a new nucleo-64 STM32L476RG. im trying to control multiple Serial slaves via the multiple uart ports on the nucleo.
the problem its most of the serial ports are printing through the USB adapter. only uart3 its printing over its respective pin. uart4 its not printing at all.
here its my code

Code: Select all

HardwareSerial Serial3(USART3);
HardwareSerial Serial1(USART1);
HardwareSerial Serial4(UART4);
//HardwareSerial Serial4(PA_1,PA_0);
//HardwareSerial Serial5(UART5,PC_12,PD_2);
HardwareSerial Serial5(UART5);
//HardwareSerial Serial5(PC_12,PD_2);
//HardwareSerial Serial5(PD_2,PC_12);

void setup() {
  Serial5.begin(9600);Serial5.println("");Serial.println("serial 5");
  Serial4.begin(9600);Serial4.println("serial 4");
  Serial3.begin(9600);Serial3.println("serial 3");
  Serial2.begin(9600);Serial2.println("serial 2");
  Serial1.begin(9600);Serial1.println("serial 1");
  Serial.begin(9600);Serial.println("serial 0");Serial.println("*****");
  
this its coming in the serial monitor:
12:26:13.036 -> serial 5
12:26:13.036 -> serial 2
12:26:13.069 -> serial 0
12:26:13.069 -> *****
please help me get this serials to work and thanks.
Last edited by paulportohernan on Wed Dec 23, 2020 2:42 am, edited 1 time in total.
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: STM32L476RG Serial Messup

Post by fpiSTM »

I've tested your code,note that I've clean it:

Code: Select all

HardwareSerial Serial1(USART1);
HardwareSerial Serial3(USART3);
HardwareSerial Serial4(UART4);
HardwareSerial Serial5(UART5);

void setup() {
  Serial5.begin(9600); Serial5.println("serial 5");
  Serial4.begin(9600); Serial4.println("serial 4");
  Serial3.begin(9600); Serial3.println("serial 3");
  Serial2.begin(9600); Serial2.println("serial 2");
  Serial1.begin(9600); Serial1.println("serial 1");
  /* Serial.begin(9600); */
  Serial.println("serial (same as 2)");
  Serial.println("*****");
}

void loop() {
  Serial5.println("serial 5");
  Serial4.println("serial 4");
  Serial3.println("serial 3");
  Serial2.println("serial 2");
  Serial1.println("serial 1");
  Serial.println("serial (same as 2)");
  Serial.println("*****");
}
And all the Serial are functional. I guess you have a mistake in your configuration. Tell us which is your config ? Core version? IDE version? Wiring ? All relevant information.
paulportohernan
Posts: 10
Joined: Sun Dec 20, 2020 4:32 pm
Answers: 1

Re: STM32L476RG Serial Messup

Post by paulportohernan »

fpiSTM wrote: Mon Dec 21, 2020 10:58 am I've tested your code,note that I've clean it:

Code: Select all

HardwareSerial Serial1(USART1);
HardwareSerial Serial3(USART3);
HardwareSerial Serial4(UART4);
HardwareSerial Serial5(UART5);

void setup() {
  Serial5.begin(9600); Serial5.println("serial 5");
  Serial4.begin(9600); Serial4.println("serial 4");
  Serial3.begin(9600); Serial3.println("serial 3");
  Serial2.begin(9600); Serial2.println("serial 2");
  Serial1.begin(9600); Serial1.println("serial 1");
  /* Serial.begin(9600); */
  Serial.println("serial (same as 2)");
  Serial.println("*****");
}

void loop() {
  Serial5.println("serial 5");
  Serial4.println("serial 4");
  Serial3.println("serial 3");
  Serial2.println("serial 2");
  Serial1.println("serial 1");
  Serial.println("serial (same as 2)");
  Serial.println("*****");
}
And all the Serial are functional. I guess you have a mistake in your configuration. Tell us which is your config ? Core version? IDE version? Wiring ? All relevant information.
thank you. my code was the mess. still not sure why the serial 4 was not printing. all its working now. thanks
Post Reply

Return to “STM boards (Discovery, Eval, Nucleo, ...)”