R32V2020 SD Card Interface
Jump to navigation
Jump to search
Based on Neal Crook's improvements to Grant Searle's Multicomp project.
- Not all FPGA cards have built-in SD Card sockets
- On other cards, should be able to wire up to IO pins (if there are any)
- SD Card Test Application dumps SD Card to the ANSI VGA screen
- Original VHDL code was based on the Multicomp design by Grant Searle
- Enhanced by Neal Crook to support SDHC cards
- SDHC can be upto 32GByte but this design can only access the low 8GByte
- Code for R32V2020 RISC CPU
; SD Card base address is x1000 ; Register Addresses ; 0x1000 SDDATA read/write data ; 0x1001 SDSTATUS read ; 0x1001 SDCONTROL write ; 0x1002 SDLBA0 write-only ; 0x1003 SDLBA1 write-only ; 0x1004 SDLBA2 write-only (only bits 6:0 are valid) ; ; To read a 512-byte block from the SDCARD: ; Wait until SDSTATUS=0x80 (ensures previous cmd has completed) ; Write SDLBA0, SDLBA1 SDLBA2 to select block index to read from ; Write 0 to SDCONTROL to issue read command ; Loop 512 times: ; Wait until SDSTATUS=0xE0 (read byte ready, block busy) ; Read byte from SDDATA ; ; To write a 512-byte block to the SDCARD: ; Wait until SDSTATUS=0x80 (ensures previous cmd has completed) ; Write SDLBA0, SDLBA1 SDLBA2 to select block index to write to ; Write 1 to SDCONTROL to issue write command ; Loop 512 times: ; Wait until SDSTATUS=0xA0 (block busy) ; Write byte to SDDATA ;