If you’re like me, one of the things you find endearing about old 80’s and 90’s computers is that had a lot of expansion options, much like the hat idea of the Pokitto. One of these expansions that was popular throughout a range of these computers was a RAM expansion of some sort.
So I present you…
The RAM HAT!
The chip I opted for was the 23LC512-I/SN SRAM Memory Chip, which is 512kbit, which is 64kB. It is accessed randomly without speed loss, so is not restricted to reading full ‘pages’ like flash memory is. Speed-wise its best to read/write large amounts of data sequentially so that you dont send the command and address over and over. In tests using TAS mode, I was able to stream a full screen 8bit (256 colour) image at about 45fps.
Looking online, I could only fine libraries to access these chips in normal SPI mode, which, although would work fine, would not use the chip to its full potential. So I had to start from scratch writing code to use the QSPI (Quad Serial Peripheral Interface) which can be likened to a 4bit parallel interface, sending data along 4 lines for every clock tick, rather than just 1.
So with help from some of the more experienced Pokitto coders, who enlightened me on the methods of reading the PEX pins lightning fast, I eventually got this device working and probably as fast as the Pokitto can manage it.
I wired up the chip as follows, keeping the SPI pins correct to hardware just in case the whole idea failed and I was forced to use SPI only. The rest of the pins are connected next to each other so that fast port reading can be used. Also, like most serial devices, it uses a CS line to know if you’re talking to it or not, meaning we could easily add multiple RAM chips with very little change to the software.
__ __ 1-| U |-8 2-| |-7 3-| |-6 4-|_____|-5 1 - CS ------------------------ P1_5 2 - SIO1 - Slave Out (MISO) --- P1_21 3 - SIO2 - Slave Out 2 -------- P1_22 4 - VSS ----------------------- GND 5 - SIO0 - Slave In (MOSI) ---- P1_20 6 - SCK ----------------------- P1_6 7 - SIO3 - Slave Out 3 / Hold - P1_23 8 - VCC ----------------------- 3v3
My working example project is https://github.com/spinalcode/Pokitto-QSPI-RAM
Here it is in action.
[update] Added support for 1024 (128k) RAM chip, just change the define at the top of ram.i to 1024 for full 128k, or something else for 64k.