Hello Jing
Thankyou for the pointers to the KLQRUG and also I pulled in the "KL25 Sample Code" and following
"KL25 Sample Code\kl25_sc_rev10\klxx-sc-baremetal\src\projects\low_power_dma_uart_demo"
and it gives me the sequence of DMA init as a reference.
I don't have the "Freedom board" to try it, I'm using a custom board that has the UART already working in simple polled mode.
The second part of my question was how to detect if there is a UART Rx char timeout?
Seems like a standard requirement for the real world - async characters arrive, and when there are no characters arriving for 'X' mSecs, an async timeout interrupt is generated in some fashion.
So I'm curious if anybody sees a solution?
If I could route the UART Rx arrival/dma request to a Timer this might work - that is the first UART Rx received initializes a count down timer and starts a countdown.
For every UART Rx after that it intializes the timer again. When the timer reaches 0, indicating no UART Rx in time period, it generates INT and wakes up the cpu.
The low_power_dma_uart_demo example has a poll of the uart, which seems to contradict the idea of being low power by having the cpu running and monitoring for a full buffer from the UART Rx. For a UART Rx its not usual to know the size of the Rx packet before it starts, so possibly not a real world example.
// Wait for the DMA buffer to become full.
while (dma_done == 0) {
if((DMA_DSR_BCR0 & DMA_DSR_BCR_DONE_MASK) == DMA_DSR_BCR_DONE_MASK) {
// Set DMA semaphore and write DMA Done bit when buffer is full.
DMA_DSR_BCR0 |= DMA_DSR_BCR_DONE_MASK;
dma_done = 1;
}
}
thanks