Hi,
I'm working on a project involving SD card writing via SPI bus. The writing itself works well, but it's terribly slow (~10kBps). I believe the reason is the SPI clock which ticks only @ 45 kHz.
The environment is as follows:
- FRDM-KL25Z board, Itead Studio SD Card breakout module, Samsung 2GB MicroSD card
- FatFS and SDCard components from www.steinerberg.com
- SPI1 bus, 333 kHz and 4 Mhz shift clock speeds
- Clock: 8 Mhz external crystal, 2 MHz bus, MCG is in BLPE mode.
- Codewarrior 10.3, OpenSDA
If I change the bus speed to 1 MHz the SPI clock reduces to 23 kHz, eventhough SPI1 shoudn't use bus clock as a reference. The MCG, SIM and SPI registers seem ok and the scope tells me the bus clock is ok (which should mean the OUTDIV1 and OUTDIV4 work as they should). I tried also SPI0 bus but that was slow as well.
So the question is: what could be the reason for such a slow clock speed?
Solved! Go to Solution.
Hi,
have you configured the SD_Card component to use a slow and a fast mode? Typically the slow mode has index zero into the clock speed table, and the fast mode has index 1.
Have a look at my Arduino SD-Card shield and the settings in Arduino Data-Logger Shield with the FRDM-KL25Z Board | MCU on Eclipse
Hope this helps,
Erich
Hi,
have you configured the SD_Card component to use a slow and a fast mode? Typically the slow mode has index zero into the clock speed table, and the fast mode has index 1.
Have a look at my Arduino SD-Card shield and the settings in Arduino Data-Logger Shield with the FRDM-KL25Z Board | MCU on Eclipse
Hope this helps,
Erich
Hi!
Thank you for your reply! Yup, I had the two speed modes in SD component and SM but that didn't give me any speedup. I changed the clocking configuration (MCG=>PEE, core=>48MHz, bus=>24MHz) which led into 413kHz SPI clock and ~42kBps write speed.
Anyhoo, I then read your article and updated the SD_Card and FatFS components. As a result, the SPI clock works as configured! Amazing! The write speed is now ~70kBps (6400B packets * 100 cycles, append to the same file) which should be enough for the project.
Thanks a lot for your help and let me know if you come up with any tricks to further boost up the write speed!
Jonas