How to set a watermark level for UART receive?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to set a watermark level for UART receive?

2,471 Views
mmjoseph
Contributor I

Hello,

I'm new to MQX and it would be really helpful if someone could tell me how to set a watermark level for UART receive? I'm using FRDM-K66F board and MQX v5.0.3. If a timeout occurs and the watermark have not been reached yet, is there any way to find out the number of bytes pending in the receive data buffer? Also, what is the best way to implement the timeout?

0 Kudos
2 Replies

1,692 Views
danielchen
NXP TechSupport
NXP TechSupport

Hi Minu:

First please check the following API to configure the RX FIFO watermark

    /* Configure the RX FIFO watermark to be 1.
     * Note about RX FIFO support: There is only one RX data full interrupt that
     * is associated with the RX FIFO Watermark. The watermark cannot be
     * dynamically changed. This means if the rxSize is less than the programmed
     * watermark the interrupt will never occur. If we try to change the
     * watermark, this will involve shutting down the receiver first - which is
     * not a desirable operation when the UART is actively receiving data.
     * Hence, the best solution is to set the RX FIFO watermark to 1. */
    UART_HAL_SetRxFifoWatermark(base, 1);

Regards

Daniel

0 Kudos

1,692 Views
mmjoseph
Contributor I

Hi Daniel,

Thanks so much. So, is it best that the watermark is set as 1? Also, I've been researching how to configure a serial port using mqx v5.0.3. In the older version, I could see that fopen, fread and fwrite were used to manipulate the serial driver and also a number of ioctl flags were there to configure the serial port parameters such as baud rate, parity and stop bits. I've build an SDK for MK66FN2M0xxx18. There, I couldn't find any ioctl flags like the older version. So, here how do I change the serial port parameters? I saw some APIs such as _nio_open, _nio_write and _nio_ioctl. Am I supposed to use these calls directly? I couldn't find any sample serial driver codes which I can reuse. It would be really helpful if someone could point me to some sample codes.

Regards,

Minu

0 Kudos