This Question is Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
1,214 Views 6 Replies Last post: Jul 14, 2009 12:17 PM by DJ Delorie RSS
DJ Delorie Novice 301 posts since
Mar 12, 2009
Currently Being Moderated

Jul 10, 2009 10:22 PM

SPI+DMA performance?

I've got an M32C/87 project that uses Uart4 in synchronous mode to talk to an SPI device (microsd card).  To speed it up, I used DMA0 to handle the block read transfers.  However, I'm noticing an approximately 3 uS delay between bytes transferred (about 60 clocks at 20 MHz), reducing the overall bit rate from 10 Mb/s to about 2 Mb/s.  The delay is approximately constant, regardless of the uart's speed.  The app is just doing a busy loop waiting for the DMA interrupt.  I tried a WAIT but that caused an even bigger delay between bytes.

 

Now, I can understand some overhead due to the fact that you have to send a byte to read a byte, but 60 clocks?  I did try writing two bytes to u4tb to try to "fill the pipeline" which works for a few bytes but then it reverts to the original timing; I assume it misses a byte and loses sync.

 

Anyone have any ideas why the fixed delay, and/or how to reduce or eliminate it?

Tags: dma, spi, m32c
FrankL Apprentice 1,100 posts since
Mar 16, 2009
Currently Being Moderated
Jul 13, 2009 12:45 AM in response to: DJ Delorie
Re: SPI+DMA performance?

How do you write the dummy byte for receiving data?

What about using a second DMA top write the dummy data to the transmit register? Or check the transmit buffer empty flag in your wait loop and write the dummy data there?

FrankL Apprentice 1,100 posts since
Mar 16, 2009
Currently Being Moderated
Jul 13, 2009 1:17 AM in response to: DJ Delorie
Re: SPI+DMA performance?

This means you run U4 with external clock and the U4RRM bit set to "1"?

With a microSD card I had expected you use internal clock, and this cannot use U4RRM bit.

FrankL Apprentice 1,100 posts since
Mar 16, 2009
Currently Being Moderated
Jul 14, 2009 12:20 AM in response to: DJ Delorie
Re: SPI+DMA performance?

The manual says RRM should be used ONLY with external clock (note 3 in the register picture). May be this causes your problems.

More Like This

  • Retrieving data ...

Bookmarked By (0)