Multiple Block Write SD protocol issue


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2009
    Location
    South Wales (UK)
    Posts
    62

    Default Multiple Block Write SD protocol issue

    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

  2. #2
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    953


    Did you find this post helpful? Yes | No

    Default Re: Multiple Block Write SD protocol issue


Similar Threads

  1. Multiple Block Write SD protocol issue
    By jimbostlawrence in forum General
    Replies: 1
    Last Post: - 16th April 2016, 14:58
  2. Multiple Block Write SD protocol issue
    By jimbostlawrence in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 14th February 2016, 20:25
  3. Lcdout multiple variables issue
    By MarkEngineer in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 23rd February 2015, 14:51
  4. DT Multiple Software PWM and 18F2321 issue
    By microuser in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 20th December 2012, 08:23
  5. SD Multiple Write?
    By jimbostlawrence in forum General
    Replies: 1
    Last Post: - 21st October 2011, 17:45

Members who have read this thread : 0

You do not have permission to view the list of names.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts