sd-cardspiz80retro-computingshift-register

SPI Hardware interface to z80


I am attempting to make a retro computer using a z80 and ideally would like to give it the ability to boot from an SD card. I am 100% set on using a z80 and do not want to use a microcontroller with an internal SPI hardware interface. I want to understand both the hardware and software aspects of a computer, so arduinos and microcontrollers are off the table as the hardware side is completed before you even purchase it. Anyways, my main question is would it be possible to combine a shift register, some decoding logic, and software to read from an SD card via SPI mode? I have searched the internet for hours and read several articles and cant seem to find a tutorial. I understand SPI protocol, however, there is a lack of information regarding the hardware side because microcontrollers tend to have all the hardware built in. I planned on connecting the SOMI of the SD card to the serial input pin of a shift register, the SIMO of the SD card to the serial out pin of the shift register, and then connecting a few data pins to some flip flops with some decoding logic inbetween, so that if I output to a specific port, it will toggle the flip flops. The flip flops would serve as the clock and chip enable lines to the SD card. I would also connect a pin of the z80 to the latch pin of the shift register (again with decoding logic inbetween) so that if I output to a specific port it will latch the data of the shift register. Im unconcerned with speed/efficiency, as long as I can accurately read data from the SD card. Also, would I connect the shift register clock input to the same clock as I connect the SD card to? Any advice on how to implement this would be appreciated, thanks!


Solution

  • You really could just bit bang SPI on regular IO's. All you need is an edge interrupt for the clock signal and a level interrupt for the chip select. Everything else can be done in software. To send, hold the chip select low, and clock out bits on MOSI at the desired rate. To receive, handle chip select going low by sampling bits off MISO on the desired edge on the clock line. Stick everything in a buffer and process the buffer when the chip select line goes back high.