AnsweredAssumed Answered

SPI/DMA issue with kinetis K64 (MK64F12)

Question asked by Mikael Elharrar on Jun 9, 2017
Latest reply on Jun 14, 2017 by Mikael Elharrar

Hi community,


I'm working on a board with

   - One external ADC which samples the analog voltage at 42 Kilo samples per seconds.

   - Each sample is 12 bytes to read from SPI. My SPI clock work at 15Mhz.

   - SPI channel of my micro (K64) is configured as master, and get a gpio interrupt each time a new sample is ready.


My micro is running free rtos.


To not disturb the execution I decided to use eDMA, to extract the samples from ADC.

For that I exactly copied the example named "espi_dma_transfer_frdmk64" (in initialization).

I have a callback each time the DMA finish the transfer (called from DMA_irq).

At the moment I'm using the gpio interrupt handler to start the DMA transfer (hopefully, this will be triggered directly by the dma if possible).



I started a capture during 20 seconds and put some counters in gpio interrupt handler, in dma transfer complete callback, and in start dma tranfer.

I get after 20 seconds:

=> 853526 times the gpio interrupt fired: It is OK because 42000 samples/sec. * 20 seconds => 840000 ~~ 853526

=> 233388 times the DMA complete transfer callback was called => no make sense at all.

=> 640144 times the start DMA function returned "Error Busy flag" (the DMA seems to be busy).

That is mean the DMA transfer take more than 23 us (more than one ADC interval), to transfer 12 bytes only.


How that is it possible ?

How to resolve this problem ?

Please help.