5 years, 4 months ago.

stm32L152, serial4 and serial 5

Hi to all i have this strange situation i write this code

#include "mbed.h"
 //Serial pc(PC_10,PC_11); //Serial 4  TX,  RX   ko
  Serial pc(PB_10,PB_11); //Serial 3  TX,  RX  //ok
 //Serial pc(PC_12,PD_2); //Serial 5  TX,  RX  //ko


DigitalOut myled(LED1);

int main() {
  int i = 1;
  pc.printf("Hello World !\n");
  while(1) {
      wait(1);
     pc.printf("This program runs since %d seconds.\n", i++);
      myled = !myled;
  }
} 

if i use Serial 3 all work well, if i use serial 4 or serial 5 don't work, can you give where is the error ?

can you help me?

best regards A.

2 Answers

5 years, 4 months ago.

If this is the case (viewing the serial output on USB), you can also add a wire from the SERIALn_TX pin you want to the CN3-RX connector. And one wire between the SERIALn_RX pin to the CN3-TX connector.

Accepted Answer
5 years, 4 months ago.

Hi Antoniolinux,

Are you trying to view this serial output through your serial console via the USB interface on the NUCLEO board?

If so then Serial 4 and 5 won't work because they aren't attached to the interface chip on the NUCLEO board. To read from Serial 4 and 5 you'll need an external serial adapter or another microcontroller/mbed.

Hope that helps, Brian