Now that we can read SD cards and have an I/O interface in place from the Z80 to do I/O mapped access to the SD card it's time to hook the two pieces together. To do this we will need to look closer at how Grant's code request blocks.
The loader code reads the status register SD_STATUS until the D7 bit is set.
The code then calls setLBAaddr.
It the writes to SD_CONTROL with 0x00 which causes the block read.
0584 026E ;================================================================================================ 0585 026E ; Read physical sector from host 0586 026E ;================================================================================================ 0587 026E 0588 026E readhst: 0589 026E F5 PUSH AF 0590 026F C5 PUSH BC 0591 0270 E5 PUSH HL 0592 0271 0593 0271 DB 89 rdWait1: IN A,(SD_STATUS) 0594 0273 FE 80 CP 128 0595 0275 20 FA JR NZ,rdWait1 0596 0277 0597 0277 CD 5E 02 CALL setLBAaddr 0598 027A 0599 027A 3E 00 LD A,$00 ; 00 = Read block 0600 027C D3 89 OUT (SD_CONTROL),A 0601 027E 0602 027E 0E 04 LD c,4 0603 0280 ; LD HL,hstbuf 0604 0280 rd4secs: 0605 0280 06 80 LD b,128 0606 0282 rdByte: 0607 0282 0608 0282 DB 89 rdWait2: IN A,(SD_STATUS) 0609 0284 FE E0 CP 224 ; Read byte waiting 0610 0286 20 FA JR NZ,rdWait2 0611 0288 0612 0288 DB 88 IN A,(SD_DATA)
Got it booting CP/M from the SD Card.
Here's the SD card attached to the Z80_PSOC.
Hooray!
Still need to get writes to the SD Card working.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.