8 years, 9 months ago.

UART-1 F411RE TX data

Hello,

On the Nucleo-F411RE , I am using UART-1 and sending the Data 0xAA (10101010) every 1 sec and UART was configured like this:

bt_uart.baud(115200); 115200;

bt_uart.format(8, Serial::Even, 1);

bt_uart.attach(UART_RX_IRQHandler,Serial::RxIrq);

As mentioned in my previous post with this initialisation my Rx handler was never called (even tried using RawSerial as suggested by Erik). Rx handler is called only when i use serial_api.c interface directly.

Even during Tx , I do not see the pattern 0xAA when I captured on the oscilloscope. There seems to be some mismatch. The data captured on oscilloscope is 101010 (2 bits 1 and 0 are missing). Is there some problem with UART-1 ?

Attached is the data captured on the oscilloscope for 0xAA. Please correct me if my understanding of the oscilloscope captured data is wrong. /media/uploads/ykd/data_sent_tx_aa.jpg

Regards ykd

2 Answers

7 years, 9 months ago.

Does anyone know if this bug has been fixed?

FYI, this bug still exists. I used the same solution given here and it works. Thanks.

posted by Josh Grauman 30 Jun 2016
8 years, 9 months ago.

It is hard to see in the picture but it looks OK. Note that UART will send LSB first, so you get:

idle=1, startbit 0, lsb=0,1,0,1,0,1,0,msb=1, stopbit=1, idle=1

So on the scope picture startbit and lsb will seem to be merged, same for msb, stopbit and idle state

Many Thanks. Since LSB is sent first and we have even parity still from the picture it looks like (Start 0 1 0 1 0 1 0 Stop), which appears to me like the parity bit (which in this case will be a 0 ) and '1' is missing. Since I am sending 0xAA (10101010) with even parity the data that must be seen on the scope with LSB sent first will be [Start 0 1 0 1 0 1 0 1 parity Stop] . Here it looks to me that 1 and parity (0) is missing.

posted by yogesh kulkarni 25 Jun 2015

Hi Wim, One small thing that i would like to add. We are communicating with a Bluetooth chip on nucleoF401RE where we exchange message with the BT chip every 250ms. The buffer inside the BT chip is never getting the data we are transmitting , however the host is receiving the data sent by the BT chip (through serial_api.c interface and not C++ interface). Probing the TX and RX lines on the BT chip we always see the traffic. I see that when we set the baud rate to 115200 bps on host , the BT chip is auto-detecting it as 114700 bps. For 9600 bps it is auto detecting as 9145 bps. I even tried setting 115200 bps on the BT chip , but during communication with host it is still setting to 114700 bps. The BT chip has no problems as it is in production and we are able to send data to BT chip from our desktop. is there any clk setting on host causing some problem ?

posted by yogesh kulkarni 25 Jun 2015

I did a quick test on the F401. There seems to be a bug in the lib when you select Parity. The Parity bit and the msb bit interfere. A quick solution is to set the number of databits to 9. That works.

bt_uart.format(9,Serial::Even,1);  //Ok parity 0xAA, 0x23

The result is shown here:

/media/uploads/wim/f401_0xaa_0x23_peven_screenshot.jpg

Please post a bugreport on github

The baudrate is not fully accurate at 115200, but close. I get 8.5625 us per bit which is 116800 bd. Make sure you have the latest mbed lib which uses the external crystal rather than the less accurate internal oscillator.

posted by Wim Huiskamp 25 Jun 2015

Wim, thanks a lot. Yes you are right 115200 is actually 116800. So I reduced baud to 113622 bps on host (so that it actually becomes 115200) and instead of 8 as you said I changed it to 9 bits (along with the latest libmbed). With this BT chip is now responding and is able to receive the data which the host sends. With this combination it is working now :-)

I am still on C interface as below. Let me move to C++ interface and see if this also works there.

below

    SerialParity x=ParityEven;// ParityEven;
    SerialIrq z=RxIrq;
    serial_init(&test,PA_9,PA_10);
    serial_baud(&test,113622);
    serial_format(&test,9,x,1);
    serial_irq_handler(&test,UART_RX_IRQHandler,1);
    serial_irq_set(&test,z,1);

posted by yogesh kulkarni 26 Jun 2015