1. Hi all,

I've been working with SD cards for a couple of years now, but only using Single Block Write. I'm trying to get Multiple Block Write to work but it fails after writing the first set.

Posting code will be difficult as it's a complicated program and would be easier if I started again, just to put something up to post.

What I've been trying so far is to use CMD25 and sending four blocks of data (4x 512 bytes) and then, once they've gone through, sending a single byte $fd using:
Code:
SDC_data_in = SSPBUF
SSPIF = 0
SSPBUF = $FD
While !SSPIF
Wend
and then raising the CS line to, in theory, finish that set of block writes.

Then, when I wish to write another set of 4 blocks (at the next available address), I do the same as above, but, after the first 512 bytes go through, I get a data not accepted error ("Unknown fail"):
Code:
for cnt = 0 to 511
     SDC_data_out = SDC_buffer[SDC_buffer_current_mul+cnt]
     gosub write_byte
next cnt

SDC_data_out = $ff
gosub write_byte	      ' send 16 1s as a dummy CRC
gosub write_byte

SDC_data_in = SSPBUF	  ' clear the buffer
SSPIF = 0		          ' clear the interrupt flag
SSPBUF = $ff		      ' shift out a dummy byte
While !SSPIF		      ' wait for receive byte
Wend

SDC_data_in = SSPBUF	  ' get the byte
If ((SDC_data_in & $0f) != DATA_ACCEPTED) Then
        SEROUT2 Serial_out,6,[$d,$a,"Unknown fail"]
        high red_led 
        gosub stop_read
endif
Does anyone have any code that successfully sets up a multiple block write to an SD card, terminates using the multiple stop token, and then successfully repeats this on the same card? I've been trying to do this for 3 days now with no success.

I also tried CMD12 but I got an Illegal Command error in the R1 response.

I have checked using a hex editor (changing the data it's writing each time to make sure it 'is' doing its job) that the 4 blocks are being written in the first multiple block write instance...

Best,

Jimbo