asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
SD driver initialization problem - PNY SD cards |
Posted: Sat Nov 01, 2008 11:21 am |
|
|
Hi,
A lot of CCS users make use of the Brush Electronics' SD card file system library or SD card utilities library. The base software for these drivers is common and has been extensively tested and is widely deployed. I recently had a CCS customer report a problem with using PNY cards. After examining one of the problem cards I determined that it failed in the initialization section where the SPI bus speed is changed from low speed to high speed.
The work around is straight forward: prior to changing the SPI bus speed, deselect the SD card, change the SPI bus speed, and finally reselect the SD card and continue card initialization. Other drivers may exhibit a similar problem with this card.
If you are using the Brush Electronics' drivers, locate the function disk_initialize which is either in diskio.h or media_io.h file. Then locate the second call to setup_spi located towards the end of the function and modify the code as per below.
Before: Code: |
// SPI Mode 0
setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_4 | SPI_XMIT_L_TO_H);
|
after: Code: |
DeselectSD;
// SPI Mode 0
setup_spi(SPI_MASTER | SPI_L_TO_H | SPI_CLK_DIV_4 | SPI_XMIT_L_TO_H);
SelectSD;
|
_________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|