Terminating LPUART Rx DMA with IDLE/ILIE (for variable length packets)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Terminating LPUART Rx DMA with IDLE/ILIE (for variable length packets)

2,078件の閲覧回数
robertpoor
Senior Contributor I

I'm writing code to support the Modbus RTU protocol with variable-length packets.  One of its distinguishing features is that the end of a packet is indicated by a gap (3.5 byte periods) in received data.

I'm working with the FRDM KL27Z dev board.  I'd like to receive Modbus packets via an LPUART DMA setup, perhaps by modifying the example given in:

    {sdk2.2.1}/boards/frdmkl27z/driver_examples/lpuart/dma_transfer/

Since the length of a Modbus RTU packet isn't known ahead of time, I need a way to stop the DMA at the end of the packet.  My thought is to enable the LPUARTx_STAT.IDLE interrupt (by setting LPUARTx_CTRL.ILIE).  When I receive that interrupt, it signifies the end of the Modbus packet, so I can stop the DMA reception in progress.

So far, I've not gotten it to work -- any pointers or examples would be welcome.

What I've tried (and what doesn't work)

I have tried adding the following to the lpuart_dma_transfer.c example:

void DEMO_LPUART_IRQ_HANDLER(void) {
    LPUART_Type *base = DEMO_LPUART;
    base->STAT |= LPUART_STAT_IDLE_MASK;
    rxBufferEmpty = false;
    rxOnGoing = false;
}
main() {
    ...
    LPUART_EnableInterrupts(DEMO_LPUART, kLPUART_IdleLineInterruptEnable);
    EnableIRQ(DEMO_LPUART_IRQn);
    ...
}

What I observe is that it calls the IRQ_HANDER repeatedly, even though I disable the IDLE interrupt.  Within the interrupt, I don't see what is causing the repeated interrupt:

    base->BAUD = 0x1f20000d
    base->STAT = 0x00c00000 

In other words, BAUD has not enabled any interrupts, and STAT indicates TDRE and TC is true but no enabled interrupts.

What am I missing?

タグ(3)
0 件の賞賛
返信
3 返答(返信)

1,579件の閲覧回数
jingpan
NXP TechSupport
NXP TechSupport

Hi Robert,
This is because the demo calls two function LPUART_EnableTxDMA and LPUART_EnableRxDMA. These two functions open RIE and TIE. So each time it received or transmit a data, an interrupt will be sent. You can delete the sentence which enable the interrupt in these two functions.

Regards

Jing

1,579件の閲覧回数
robertpoor
Senior Contributor I

Jing:

Thank you.  

If I disable RIE and TIE, will the DMA module still receive data?

0 件の賞賛
返信

1,579件の閲覧回数
jingpan
NXP TechSupport
NXP TechSupport

Hi Robert,

Yes it will.

Regards

Jing

0 件の賞賛
返信