NUCLEO-F303RE and RS-232 module

Hello.
I try to use NUCLEO-F303RE(STLink is intact) with Robotdyn RS-232 module and/or DFRobot RS-232 shield. These boards are 100% working with Arduino boards. TX, RX of these boards(one in time) are connected to (PA2, PA3). The code is simple:

#include “mbed.h”
#include “BufferedSerial.h”

// Create a BufferedSerial object with a default baud rate.
BufferedSerial pc(PA_9, PA_10);

int main() {
// Set desired properties
pc.set_baud(9600);
pc.set_format(
/* bits / 8,
/
parity / BufferedSerial::None,
/
stop bit */ 1
);

// Hex string to be sent
uint8_t hex_string[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x82, 0x11, 0x50, 0x43, 0x2A, 0x89};

while (1) {
    // Write the hex string to the serial port
    pc.write(hex_string, sizeof(hex_string));
    
    // Wait for 10 seconds
    ThisThread::sleep_for(10s);
}

}

Nothing happens on a serial port. No data is sent. But if I change to USBTX/RX, I see the data sent to a PC console.

Tried to use (PA9, PA10) instead of (PA2, PA3). Nothing happens.
What`s wrong with it?

Hi,

Nothing happens on a serial port. No data is sent. But if I change to USBTX/RX, I see the data sent to a PC console.

Did you actually check the PA_9 signal on the shield? Or, RS232 output?

The code looks fine for me, but you might check the hardware spec of the DFRobot RS-232 shield. According to the schematics, it uses +5V for the VCC and there is no 5V/3V3 level shifter on the board (it directly connect the 3V3 IOs of the STM32F303RE to the MAX3232 device).