AnsweredAssumed Answered

Interrupt Driven LPUART Transmits Zeros

Question asked by Jim Fell on Jul 11, 2018
Latest reply on Jul 13, 2018 by Jim Fell

I'm using the MKL17Z256VLH4 with interrupt-driven LPUART0.  When transmitting more than one byte the following bytes are always zero, regardless of what is passed to the subsequent calls of LPUART_WriteByte(), which is in LPUART_TX_RX_IRQHandler().

 

Here is just the transmit portion of my ISR:

if(kLPUART_TxDataRegEmptyFlag & status && (((LPUART_Type*)UART_SEL[uart])->CTRL & LPUART_CTRL_TIE_MASK))

{
    if(TxMsg[uart].pos < TxMsg[uart].length && SCI_PAR_NONE2 != TxMsg[uart].parity) {
        LPUART_WriteByte(UART_SEL[uart], TxMsg[uart].data[TxMsg[uart].pos++]); // << breakpoint here
    } else {
        // Message is sent.
        LPUART_DisableInterrupts(UART_SEL[uart], kLPUART_TxDataRegEmptyInterruptEnable);
        LPUART_EnableInterrupts(UART_SEL[uart], kLPUART_TransmissionCompleteInterruptEnable);
    }
}

 

I noticed that when I set a breakpoint on the call to LPUART_WriteByte() the data bytes started transmitted correctly (most of the time), so I added a software delay to see what would happen:

 

for (int i = 100000; i > 0; i--);
LPUART_WriteByte(UART_SEL[uart], TxMsg[uart].data[TxMsg[uart].pos++]);

 

The data started coming through (monitored with RealTerm), but it's inconsistent.  Clearly there is something wrong here.  I've stepped through and verified, using the expressions and memory view windows in KDS, that the data being sent to LPUART_WriteByte() is correct.  I've also connected a logic analyzer to the LPUART0 transmit and receive lines and verified that the data coming out of the micro is not correct. 

 

There's clearly something wrong with either the LPUART0 or my use of it.  Any insight anyone can offer would be much appreciated.

Outcomes