UART RX interrupt with no data

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

UART RX interrupt with no data

1,284 Views
biafra
Senior Contributor I

Hi everyone,

I'm using MCUXpresso 10.2.1 with a custom board based on MK66F2M0.

I'm facing with a strange situation: sometimes I get the UART interrupt handling the RX data register full event, but in the buffer there is no data available.

/* Receive data register full */
if ((UART_S1_RDRF_MASK & base->S1) && (UART_C2_RIE_MASK & base->C2))
{
   /* Get the size that can be stored into buffer for this interrupt. */
#if defined(FSL_FEATURE_UART_HAS_FIFO) && FSL_FEATURE_UART_HAS_FIFO
   count = base->RCFIFO;
#else
   count = 1;
#endif
  ...

}

In this situation I get count = 0.

Why there is the rx data event and no data is available?

How can this situation be generated?

Many thanks

Biafra

4 Replies

968 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi biafra,

   Please debug your code, add the two breakpoint here:

if ((UART_S1_RDRF_MASK & base->S1) && (UART_C2_RIE_MASK & base->C2))
{
   /* Get the size that can be stored into buffer for this interrupt. */
#if defined(FSL_FEATURE_UART_HAS_FIFO) && FSL_FEATURE_UART_HAS_FIFO
   count = base->RCFIFO; // add break point here
#else
   count = 1;
#endif
  ...

}

Can you enter the red code when you debug the code in the interrupt?

Besides, please check you code, do you enable FSL_FEATURE_UART_HAS_FIFO?

If you don't enable the fifo, you need to read the UARTX_D register to clear the RDRF.

You also can check your UARTx_S1, and UARTX_S2, and send me the debug register result when you enter the interrupt.

If you have the oscilloscope, you also can check the RX pin wave, whether there have the interference or really have the UART RX wave.

Any updated information, please kindly let me know.


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

968 Views
biafra
Senior Contributor I

Hi kerryzhou‌,

In MK66F18_features.h file there is

#define FSL_FEATURE_UART_HAS_FIFO (1)

So the line

count = base->RCFIFO;

is executed.

There is no interference in RX pin.

When count is 0, I have S1 = 0xE0 and S2 = 0x41.

The UART driver is the one that is supplied with SDK!

Many thanks

Biafra

968 Views
kerryzhou
NXP TechSupport
NXP TechSupport

Hi MERIGOT BERTRAND,

   Please use the oscilloscope to check your RX pin during your debugging, I want to see the RX wave.

   Besides, do you have the official K66 board on your side, you can also try our official board, check whether your code still have this problem?


Have a great day,
Kerry

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

968 Views
merigotbertrand
Contributor III

Hi everyone,

Your software is correct for me.

Sometimes this kind of problem could occured by a stress on Vdd or Gnd or another input which face an abnormal voltage / interference which "press" on RX pin reference and can generate an interruption.

Verify that there is no interference on any I/O.

Regards

Bertrand.