Issue with UART Read Flags Not Triggering

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

Issue with UART Read Flags Not Triggering

192 Views
andrtnnr
Contributor II

Hi everyone,

I'm working on an NXP project that involves reading ADC values and transmitting them over UART, and receiving responses from a co processor over UART. I'm using the FRDM-MCXW71 evaluation board and have encountered an issue where the UART RX read flags don't seem to work as expected when sending data to the RX line.

Context

  • Platform: FRDM-MCXW71 evaluation board (details in code below).
  • UART Configuration:
    • Baud rate (9600) and other settings are correctly configured using LPUART_GetDefaultConfig.
    • TX and RX are both enabled.

Problem

The RX read flag (kLPUART_RxDataRegFullFlag) isn't triggering during runtime when I send data to the RX pin. This suggests that incoming data isn't being flagged for processing even though the UART peripheral is initialized and configured correctly.

What Works

When I switch to using blocking reads via LPUART_ReadBlocking, the UART receives data without any issues. This confirms that the hardware setup and basic UART functionality are working fine.

Here’s the working example using LPUART_ReadBlocking:

uint8_t data[10];  
LPUART_ReadBlocking(LPUART0, data, sizeof(data));  
PRINTF("Received: %s", data);  

What I Tried

  1. Ensured that RX is enabled (config.enableRx = true).
  2. Verified interrupt configurations (though they aren't relevant for blocking reads).
  3. Confirmed the TX functionality works perfectly, and RX behaves as expected in blocking mode.

Code Snippet

Here’s the part of the UART setup code:

static void configureLPUART(void)  
{  
    lpuart_config_t config;  
    LPUART_GetDefaultConfig(&config);  
    config.baudRate_Bps = UART_BAUD_RATE;  
    config.enableTx = true;  
    config.enableRx = true;  

    LPUART_Init(LPUART0, &config, DEMO_LPUART_CLK_FREQ);  
    LPUART_EnableInterrupts(LPUART0, kLPUART_RxDataRegFullInterruptEnable);  
}  

However, checking LPUART_GetStatusFlags(LPUART0) & kLPUART_RxDataRegFullFlag doesn't seem to indicate any data received, even when valid data is sent to RX.

Mex config

andrtnnr_0-1734880060734.png

Question

Has anyone experienced similar issues with the RX flags not being triggered? Could this be related to clock settings, buffer configuration, .mex config or something I might be overlooking in the LPUART setup?

Any insights would be greatly appreciated!

Thanks in advance!
Andrew

Labels (3)
Tags (3)
0 Kudos
Reply
7 Replies

154 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @andrtnnr 

Thanks for your question.

Do you want to use Interrupt mode or Polling mode? If interrupt, please refer to lpuart_interrupt_transfer under SDK demo. It calls RX read flag (kLPUART_RxDataRegFullFlag) .

Alice_Yang_0-1734924334976.png

BR

Alice

 

0 Kudos
Reply

121 Views
andrtnnr
Contributor II

@Alice_Yang lpuart_interrupt_transfer doesnt use LPUART_TransferHandleIRQ. 

Im not sure this is helpful.

I would love to learn what to debug if my current methods arent working

0 Kudos
Reply

109 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @andrtnnr 

The demos "lpuart_interrupt_rb_transfer" and "lpuart_interrupt_transfer" 

use  LPUART_TransferHandleIRQ(). You can refer to.

Alice_Yang_0-1735184431327.png

BR

Alice

0 Kudos
Reply

9 Views
andrtnnr
Contributor II

Hey @Alice_Yang,

That seems to work. Thanks for the help.

0 Kudos
Reply

87 Views
andrtnnr
Contributor II

Thanks @Alice_Yang . I have this demo running and receiving data.

But I have a problem with understanding how to modify the example to fit my needs. I want to use this similar to an Arduino serial call like Serial.Available() but this one seems to wait until the rx buffer size hit its limit (in this example its 8 characters). How would I trigger a read if I want to read once my coprocessor is done sending regards if its hits the limit.

0 Kudos
Reply

43 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @andrtnnr 

In this demo, it will call the function LPUART_ReadByte() to read data from the receiver register after receiving one dataword.

Alice_Yang_1-1735615533518.png

 

BR

Alice

 

 

 

 

0 Kudos
Reply

184 Views
andrtnnr
Contributor II

How I am accessing the flags

 

 while (LPUART_GetStatusFlags(LPUART0) & kLPUART_RxDataRegFullFlag) {

 

0 Kudos
Reply