How to use a circular buffer (ADDRESS MODULO) with Kinetis L DMA?

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

How to use a circular buffer (ADDRESS MODULO) with Kinetis L DMA?

1,572 Views
mjbcswitzerland
Specialist V

Hi All

I am wondering about the address modulo option in the Kinetis L DMA.

It allows the use of a buffer or 16, 32, 64, 128, 256, ..  up to 256kB in size (it needs to be on a modulo address boundary and have the modulo bytes size) but allows a single DMA controller channel to manage a circular buffer. This is useful - for example - to sample an ADC input channel to so that it keeps filling the buffer until the end and then starts at the beginning again.

The requirements is that the transfer size programmed must be a multiple of the buffer size for it to be able to start but there is a maxiumum that can be set (0xfffff is the limite - but respecting the multiple buffer length requirement). For a buffer of 512 bytes in size the maximum number of bytes is therefore 0xffe00, which is 2047x the buffer. When this operatrion runs it runs until the circular buffer has been repeated 2047 times and then stops. If the ADC were to be sampled at 8kHz (for example) it would allow the operation to run autonomously for 131s before it stops.

But what if one wants it to run forever as would be typical in such a design with a free-running circular buffer?

I tried writing the value 0xffe00 to the BCR register while DMA was running, which set the count value back and so extended the period before it stopped. But is this what is intended? It there is risk involved (configuration error resulting at certain count values)? Is there a better way to achieve the infinite free-running solution using a single DMA channel?

Regards

Mark

Labels (1)
Tags (2)
2 Replies

694 Views
Carlos_Musich
NXP Employee
NXP Employee

Hi Mark,

DMA in Kinetis L family is a very basic module, it does not support such functionality. On the other hand DMA controller on Kinetis K family is much more robust and you can implement the scenario you are asking for.

Regards,

Carlos

694 Views
mjbcswitzerland
Specialist V

HI Carlos

Thanks - it did look like this was missing. I already have the eDMA interface for the K family (http://www.utasker.com/docs/uTasker/uTaskerADC.pdf) and am trying to complete a compatible DMA interface for the KL family (family independent HAL).

I believe that I have a workaround for it but haven't completed tests of long term reliability yet.

It is a shame that the counter doesn't overflow - as the circular buffer does - which would have made the module more flexible but with a bit of trickery I still believe it can be done.

Regards

Mark

0 Kudos