K60 SPI In DMA Mode has TX Underflows

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

K60 SPI In DMA Mode has TX Underflows

558 Views
norton256
Contributor III

Hello,

I'm currently running into a problem where the SPI on some boards run into TX underflows when configured to use DMA.

My K60 is set up for the SPI to run in slave mode, 16 bits, with ~6MHz clock from master device. The DMA channel is configured to use scatter gather, so that all I really need to do in the interrupt is set the request enable for that DMA channel.

What I am finding is that the SPI peripheral triggers a TX Underflow interrupt in the middle of a DMA transfer!?!

Here is a dump of the TCD when the underflow occurs:

Breakpoint 4, SpiIntIsr (arg=0) at Spi.c:1826

1826          inst_handle->mErrorTxUnderflow++;

$7 = {SADDR = 0x1fff5e24, SOFF = 0x4, ATTR = 0x202, {NBYTES_MLNO = 0x4, NBYTES_MLOFFNO = 0x4, NBYTES_MLOFFYES = 0x4}, SLAST = 0x0, DADDR = 0x4002c034, DOFF = 0x0, {CITER_ELINKNO = 0x1fb, CITER_ELINKYES = 0x1fb}, DLAST_SGA = 0x0, CSR = 0xa, {BITER_ELINKNO = 0x200, BITER_ELINKYES = 0x200}}

(gdb)

I am running bare metal.

Thanks!

0 Kudos
2 Replies

358 Views
mjbcswitzerland
Specialist V

Nick

Do you have other burst mode DMA taking place? If you do you may need to set up the crossbar switch to allow peripheral DMA to get a share of the bandwidth.

I use a lot of memory to memory DMA and could see that the USB peripheral was aborting often (having to repeat) because its output was underflowing.

By switching the crossbar switch to round-robin mode (rather than allowing higher priority sources to have full bandwidth during bursts) allowed them to all live peacefully together again. Something like:

AXBS_CRS0 = AXBS_CRS_ARB_ROUND_ROBIN;

AXBS_CRS1 = AXBS_CRS_ARB_ROUND_ROBIN; // flash and SRAM slaves priority set to rotating so that SW DMA transfers don't block peripheral transfers

Regards

Mark

0 Kudos

358 Views
norton256
Contributor III

Hi Mark,

That was very helpful. While it was not 100% of my problem, it helped point me to another logic error in my code. Now the same thing is occurring but only at temperatures above 45 deg C!

Thanks,

Nick

0 Kudos