Go Down

Topic: SD Card bitmap read error/bug? (Read 2 times) previous topic - next topic


Sep 23, 2012, 10:54 pm Last Edit: Sep 24, 2012, 04:23 pm by frollard Reason: 1
Once again thanks for the help;

My biggest trouble is I'm using the fastSPI library, and that pointer was set up by the library example - it would stand to reason if I want to use the spi output (addressable RGB leds are painfully slow to bitbang) -- I would need the data to be in the format required by the library.  

*Should have posted before:

is the code I can't seem to edit because it has no line breaks.  I wouldn't know where it begins or ends - it does seem well commented though.

EDIT: So, I got it working, sort of with the existing code, and I remember after I changed it now why it was the way it was;

I'm using SPI to read the card.
I'm using SPI to shift the data out (for speed).  I need to close the file before calling the shiftout function or it crashes.  It could also be my shiftout library that just plain crashes with other stuff on the SPI bus also.  Guess I'm stuck not using the SPI shiftout code or I'm hooped.  Having to close the file every iteration definitely slows things down.  Right now I can read the 192 bytes I need into the array (pointer) in about 6 ms, reliably.  shifting out is now the problem.


Newest version attached; now has a the mentioned bug but doesn't crash at least.

Any thoughts on how this can be mitigated?  I've tried everything I can think of!


now has a the mentioned bug but doesn't crash at least.

Something seems to be missing from this sentence. Can you summarize what the problem is?


Sep 27, 2012, 01:18 pm Last Edit: Sep 28, 2012, 04:26 am by frollard Reason: 1
Cross posted to the FastSPI code page:

I'm pretty sure the FastSPI code/pointers are stepping on the memory buffer area of the SD library.
If I never call the fastSpi.show() function it reads the bitmap and serial.print's it just fine.  If I call fastspi.show (the whole point of this exercise) every 8 and 8+2 lines have errors in them -- seemingly totally random data...amounts to every 1500 or so bytes.

Attached are the files for your viewing pleasure;

The log files are legend:
line number of the bitmap file : byte address requested of the SD library:  byte address returned : 192 data bytes

Found a fix at a big performance hit:
David suggested putting a myFile.peek(); before each myFile.read(); .  No idea why it works, but it does.  It costs 17ms / 192 bytes read instead of just 7ms/ 192 bytes, but it works.

Go Up