Playing with SPI RAM

Topics related to the API, programming discussions & questions, coding tips, bugs, etc. should go here.
User avatar
Jubatian
Posts: 1564
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Playing with SPI RAM

Post by Jubatian »

I tried a few things, normally simply deasserting the Chip Select of the SD should work, but it doesn't (since it is low active, simply resetting Uzebox would start with it being asserted, so ther's a certain conflict). It felt ridiculous, did some research with only people struggling about the issue but never resolving... Then found that the SD has some "quirks" that it won't simply let that MISO go.

Finally I thought what if... So what if I just handled the SD card like an SD card. There comes CunningFellows's sdBase (which is already part of the master kernel), did a simple sdCardInitNoBuffer() before going on to the SPI RAM thing, and at last, it works! So if you treat the thing like it should be treated, it will behave, it seems :) (and something using the SPI RAM is very likely using it since it wants to put data on it fetched from somewhere, so...)
User avatar
uze6666
Site Admin
Posts: 4801
Joined: Tue Aug 12, 2008 9:13 pm
Location: Montreal, Canada
Contact:

Re: Playing with SPI RAM

Post by uze6666 »

Another great find Jubatian! I recall experiencing this very same noise and somehow relating it to the SD interface but I could find a fix at that time. So the trick is just to put the SD card in a known state and then deassert it to use the SPI RAM. Even if the game does not need the sd (which would be doubtful as you remarked), using Cunning's sd lib is ok. Unused functions will just be optimized away anyway. I've added a note to the wiki's SPI RAM page to this effect.

Thanks for the troubleshooting! 8-)
User avatar
D3thAdd3r
Posts: 3222
Joined: Wed Apr 29, 2009 10:00 am
Location: Minneapolis, United States

Re: Playing with SPI RAM

Post by D3thAdd3r »

If you have a code snippet that shows reading from SD and writing to SPI and the de/assertions etc required in between, I would be very grateful to see a working implementation :)
User avatar
Jubatian
Posts: 1564
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: Playing with SPI RAM

Post by Jubatian »

I didn't make such, just experimented with the SPI RAM demo attempting to find the proper solution, adding the mentioned SD code to it. One could make a version of this which loads the image from the SD card and writes it into the SPI RAM. Interestingly if you did it the "natural" way, it would likely just work as for this you would naturally init and start loading from the SD card first.
Post Reply