SD cards on ARM/LPC

From HeepyWiki
Revision as of 08:34, 17 January 2012 by Morris (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

the original SPI mode code in sd_spi.c was completely failing to wait for the card to complete writes by polling for BUSY state before sending another packet. most cards don't need it but some do, and it's certainly required.

My OCZ 8g SD card still doesn't probe on the first try, but does on the second. when writing it shows a fair number of pauses. some cards don't show any. they're all very different.

also I had to increase the timeout in wait_busy() from 50 to 255 clock units which eliminated a lot of failures, so apparently you sometimes have to wait quite a while.

rev 381 of alternate_sd_spi.c seems to work with every card perfectly, except for the 8g OCZ, which still needs to be initialized twice.

4/5/2010 - added the hd44780 lcd driver too. the LCD needs six gpio pins: four for the data bus, one enable line, and "RS" data4-7 are on P0.10,11,12,13. E is on P0.9, RS is on P0.14, which is the BSL selector input, but that doesn't matter. this code is using the dedicated SPI bus, and it's CS line is on P0.8. None of this would be difficult except that if you have the chip in debug mode, for example to use a JTAG debugger, it disables almost all the rest of the gpios, eg P0.22-31.