Kinetis SDK 2.0 DMA UART continuous receiver

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

Kinetis SDK 2.0 DMA UART continuous receiver

686 Views
sgmamike
Contributor I

Hi !

I've seen a few posts about this, and it looks like people are using uTasker to achieve this. I do not have this option. 

Instead, my task loop is constantly checking UART status, in order to manage reads from the DMA buffers.

I am seeing some odd behavior. I'm using Keil 5.17 with an MKV58F1M0VLQ24.

I am trying to loop, check the status of the receiver, and kick off a DMA read when there is data. 

My application involves streams of 7 byte chunks that can either be concatenated, or a few milliseconds apart. 

Currently, there is no sleep time in my task loop in an effort to keep the receiver synchronized.

When I check the status register, I am seeing some odd combinations of states. 


c00000c0 - before the application starts chatting
80000000 kUART_TxFifoEmptyFlag
40000000 kUART_RxFifoEmptyFlag
00000080 kUART_TxDataRegEmptyFlag
00000040 kUART_TransmissionCompleteFlag

40000000 - when the application kicks off a downstream packet
40000000 kUART_RxFifoEmptyFlag

840040e8 - this happens somewhere around when 2 packets are received back to back (no space) 
80000000 kUART_TxFifoEmptyFlag
04000000 kUART_RxFifoOverflowFlag - over flow because I didnt get to it in time? Do I need to clear this?
00004000 kUART_RxActiveEdgeFlag - This stays persistent, does it need to be cleared manually?
00000080 kUART_TxDataRegEmptyFlag
00000040 kUART_TransmissionCompleteFlag
00000020 kUART_RxDataRegFullFlag - despite being full, my callback is never called after issuing a read
00000008 kUART_RxOverrunFlag - over run from 2 adjacent payloads?

c40040d0 - This follows my failed attempt to read the packet
80000000 kUART_TxFifoEmptyFlag
40000000 kUART_RxFifoEmptyFlag
04000000 kUART_RxFifoOverflowFlag
00004000 kUART_RxActiveEdgeFlag
00000080 kUART_TxDataRegEmptyFlag
00000040 kUART_TransmissionCompleteFlag
00000010 kUART_IdleLineFlag

c50040c0 - This is the steady state after my failed read attempt. 
80000000 kUART_TxFifoEmptyFlag
40000000 kUART_RxFifoEmptyFlag
01000000 kUART_RxFifoUnderflowFlag - it seems to have underflowed after the overflow. It seems to be unsync'd
04000000 kUART_RxFifoOverflowFlag
00004000 kUART_RxActiveEdgeFlag
00000080 kUART_TxDataRegEmptyFlag
00000040 kUART_TransmissionCompleteFlag

If I send the downstream request, and immediately request an EDMA read inside my ISR, 

I can see a 7 byte ACK payload, but then I can receive nothing after this. 

All I am trying to do is receive 7 bytes asynchronously. This has been pretty easy on other platforms even with DMA.

Does anyone have any feedback on flag management to make this work? Thanks

Tags (1)
0 Kudos
1 Reply

521 Views
mjbcswitzerland
Specialist V

Mike

Even if you can't use uTasker you can still copy its technique (DMA drivers etc.) from the Open Source version on Git Hub. The supported version also works with FreeRTOS and Keil.

Technically you should never need to use any UART flags and you should never be able to have any Rx overruns (even if the debugger pauses the processor it won't lose data or overrun if the DMA operation is correct). Continuous UART reception doesn't (usually) require any interrupt operation (which could cause race states and possibly other complications, resulting in unreliability). In case you have fixed length reception, half-buffer interrupts are useful since they still don't stop DMA operation but allow an interrupt based event to signal that a message is ready.

Regards

Mark

uTasker developer and supporter (+5'000 hours experience on +60 Kinetis derivatives in +80 product developments)
Kinetis: http://www.utasker.com/kinetis.html

0 Kudos