AnsweredAssumed Answered

S32K146 LPUART EDMA failed

Question asked by Xiaoyu Zhao on Aug 6, 2019
Latest reply on Aug 14, 2019 by Diana Batrlova

Hi expert,

I have a problem, I use lpuart module of S32K146 to implement UART transfer function between Modem and MCU.

I Set the uart parameter: Baud Rate 230400, No parity, Stop Bit 1, 8 bit per char, DMA, using edmaController1, Rx DMA Channel 1, Tx DMA Channel 0.

Then i test the data transfer(MCU Send and Receive Data), after about 1 hour testing, the Programm will Crash in LPUART_SetReceiverCmd(base, false) , the LPUART CTRL Register bit RE is set  to 0(false), but when crash happend, i read its value is 1. 

The while loop below can not break out:

static inline void LPUART_SetReceiverCmd(LPUART_Type * base, bool enable)


   base->CTRL = (base->CRTL & ~LPUART_CTRL_RE_MASK) | ((enable ? 1UL : UL) << LPUART_CTRL_RE_SHIFT);

   while((bool)((base->CTRL & LPUART_CTRL_RE_MASK) != 0U) != enable){} //crash point loop can not break out.


I reaad the LPUART CTRL Register bits ORIE, NEIE, FEIE, PEIE, all of the 4 bit is 1.

I check the crash stack, find that:

EDMA_DRV_IRQHanler()  -> LPUART_DRV_RxDmaCallback() -> LPUART_DRV_StopRxDma().

In LPUART_DRV_RxDmaCallback()  it goes to the else branch to call StopRxDma function. 

if(lpuartState->rxSize >0)









I want to know why in function LPUART_SetReceiverCmd(base, false);

Code: base->CTRL = (base->CRTL & ~LPUART_CTRL_RE_MASK) | ((enable ? 1UL : UL) << LPUART_CTRL_RE_SHIFT);already set RE bit to 0, but its value keeps 1,

 which cause the  while loop next line cannot break out.

What condition  can cause the set register RE bit action fail?

How to fix the bug?