PDA

View Full Version : teensy 3 unconnected SPI speed and SD speed



manitou
02-02-2013, 04:58 PM
The SdFat library provides optimized SPI functions that utilize 16-bit frames and the FIFO. I ran some simple unconnected SPI transfers using the teensy 3.0 SPI library (Paul's clever AVR emulation) vs the SPI functions in the SdFat lib. Results for the teensy, DUE, and maple are found in the file SPIperf.txt at

https://github.com/manitou48/DUEZoo

The teensy optimized SPI functions are real close to the SPI clock rate, so a DMA version (TBD) won't run much faster, but could free up the MCU for doing other tasks.

You can get impressive SD performance using the SdFat library as described in this thread
http://forum.pjrc.com/threads/16758-Teensy-3-MicroSD-guide
I ran some lower-level SD tests of 512-byte block read/writes (using card.readBlock() and write.Block()) with the default SPI library and the SdFat library. I had to hack Sd2Card.cpp to get all the SPI clock rates I wanted (ctar). The low-level block data rates for a SANS 8GB card are found at the github URL above in the file SDperft.txt

ZTiK.nl
02-11-2013, 04:19 AM
I just noticed that a new SdFat (beta) update (http://code.google.com/p/beta-lib/downloads/list) has been released which includes 'Updated SPI driver for Teensy 3.0'
Maybe able to squeeze just a little bit more out of it ;)

manitou
02-11-2013, 07:50 PM
I just noticed that a new SdFat (beta) update (http://code.google.com/p/beta-lib/downloads/list) has been released which includes 'Updated SPI driver for Teensy 3.0'
Maybe able to squeeze just a little bit more out of it ;)

Thanks for the heads up. The new version looks to be a little more conservative, adding a PCS to SCK delay as a function of SPI clock rate. The highest speeds aren't changed (no delay added), but for 8 MHz, unconnected rate goes from 7.91 mbs (megabits/sec) to 7.74mbs for the lastest SdFat version. Similary, 4 MHz slows from 4.04 mbs to 3.92mbs. Similar delays are used in Paul's SPI (AVR emulation). Not a big performance change.

Note the comments in the teensy section of Sd2Card.cpp are not correct. Comments state clock rate for spirate of 6 is 3mbs, for case of BR(2). It's really 4mbs. BR(2) from manual is a divisor of 6 not 8 (48/2/6 = 4). BR values go 2,4,6,8,16 ...

ZTiK.nl
02-11-2013, 09:07 PM
No problem, thank you for posting information like this.

For somebody who still has to learn a lot, it is pretty hard to find relevant information unless you know how to find it/what to look for (esp. in a different language).