Interrupt UART problem

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

Interrupt UART problem

961 Views
Sebast
Contributor II

Hello,

Before I work on S32K146.

I have an issue with UART's interruption, let me explain you the topic:

the UART behavior is perfect, in reception and transmission, and the interruption is correct too.

But when I have a glitch on Tx pin (only one glitch not other data), it generates an interruption, but when the SW goes out interruption, it comes back directly in this interruption, and this continously up to the watchdog reset the µc.

I do not understand why because the interruption is always called because just before out the interruption I refresh the STATUS register like this 

 LPUART0->STAT = FEATURE_LPUART_STAT_REG_FLAGS_MASK;

with FEATURE_LPUART_STAT_REG_FLAGS_MASK  = 0xC01FC000

as described in the datasheet

So do you konw why and what's happen ?

0 Kudos
6 Replies

900 Views
Sebast
Contributor II

Hello Robin,

I did some tests to understand what's happened. But let me explain you, before, how my interruption function is built:

void LPUART0_RxTx_IRQHandler(void)
{

   /* Check if error */
   {
      /* Clear the error/interrupt flags */
      LPUART0->STAT = FEATURE_LPUART_STAT_REG_FLAGS_MASK;
      return;
   }

   if ( Check if data received )

   {

      /* Save data received in buffer */

   }

   if ( Check if data transmited finished )

   {

      /* check if other data to send */

      /* If yes, load data transmitted register with new */

   }

   /* Clear the error/interrupt flags */
   LPUART0->STAT = FEATURE_LPUART_STAT_REG_FLAGS_MASK;

}

To test the SW behaviors, I use a µc pin the check in real time

See below the tests done:

1 - Remove watchdog

When the glith occurs, and without watchdog, the UART interruption is called continously (infinitely)

2 - In debug mode

When the glitch occurs, the STAT register is

STAT = 0x50FAC000  (flags :RXEDGI, RXINV, RWUID, BRKDE, LBKDE, RAF, OR, FE, MA1F & MA2F)

after clear register:

STAT = 0x10F00000

3 - Interrupt function

When the glith occurs, the interruption function is called permanently up to watchdog --> Not normal

4 - Error data

When the glith occurs, the Error data is detected only one time --> Normal it is only one glitch

5 - Received data

When the glith occurs, the received data is detected one time --> Not normal, why read data if it is an error ?

6 - Transmited data

When the glith occurs, the transmited data are sent correctly --> Normal

 

I hope my tests will help you in your analyse.

 

Have a nice day

 

Sebastien

 

0 Kudos

877 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Your LPUART0_RxTx_IRQHandler looks similar to LPUART_DRV_IRQHandler in SDK. Please check lpuart_echo_s32k146 example in SDK, will the glitch cause this phenomenon too?(I don't know which S32DS are you using. Here is the link of latest SDK RTM4.0.2)

lpuart_echo_s32k146 LPUART_DRV_IRQHandler.png

2. Did you enable all those listed interrupt of Flag in LPUART Control Register (CTRL)? Can you disable some of them so you can easily filter out which flag caused it?

0 Kudos

852 Views
Sebast
Contributor II

Hello Robin,

 

the issue is fixed, in fact, in the interrupt function, as explained before, the first thing that I do is to test if there is an error. And if there is an error, I clear all the flags with:

LPUART0->STAT = FEATURE_LPUART_STAT_REG_FLAGS_MASK;

And I go out of function.

But if the error is due to wrong received data, the receive data register is not flush (because I do not read this register), that means the IT function is always called.

So the solution is :

/* Clear the error/interrupt flags */
LPUART0->STAT = FEATURE_LPUART_STAT_REG_FLAGS_MASK;
/* Flush the receive data register to avoid to call continously the interruption function, if error is due to wrong data received */
ch = (uint8_t)LPUART0->DATA;

 

Best regards

939 Views
Sebast
Contributor II

Hello Robin,

In normal condition, the UART communication works perfectly, that means the interruption function works perfectly. But when there is a short glitch on Tx pin (just glitch no other data), due to USB adaptor, unplug and plug to my laptop), a flag (I do not know which one is  it) seems not remove whereas, for me, I clear all flags before going out to IT function.

I do not use the eval board, and I do not use the RTD example.

 

Have a nice day

0 Kudos

931 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

To debug the UART's interruption problem you mentioned, please turn off the watchdog and just check which flag is causing the repeated entry interrupt.
Set a breakpoint at the UART's interruption entry. Without send and receive, just let the USB adaptor unplug and plug to your laptop. Check the value of the STAT register at this time during debug.

What does the USB adaptor do in your system, is it just powering the system?

Why this glitch only affects the Tx Pin, doesn't it interfere with other places, such as Reset_b or Rx Pin?

0 Kudos

945 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Sebast,

What kind of glitch on TX pin can generate interrupt? (How can I reproduce this problem)

Have you test it on S32K146EVB with SDK or RTD example, will the glitch caused same interrupt too?

Which interrupt did it cause? Did you check the relevant flags after entering the interrupt to see which flag is caused it?

Best Regards,
Robin

0 Kudos