title: When reading an SD card in SPI Mode, how do I distinguish a data token from an error token?
body: <p>For SPI read, send CMD27, get back command response followed by either data token and data or error token.</p>
  
  <pre><code>Data token is  1 1 1 1 1 1 1 0
  Error token is 0 0 0 X X X X X
  </code></pre>
  
  <p>The problem is as far as I can tell, idle reads as a stream of 1 bits so if I lay the mask like this on the error token I get a valid data token:</p>
  
  <pre><code>                    start error token here
  1 1 1 1 1 1 1 1 1 1 0 0 0 X X X X X X 1 1 1 1
        start data token here
  </code></pre>
  
  <p>If the first data byte read starts with two zero bits (highly probable), this is ambiguous with error token. Looking for end of stream doesn't work as this yields infinite 1 bits. (I anticipate long streams of 1 bits in legitimate reads).</p>
  
  <p>It gets worse considering CMD28 reading across a bad sector (I need long range CMD28 to make my performance requirements). Looking for end of stream swallows the next data start packet.</p>
  
  <p>I do in fact have code (about 70 lines) that can successfully initialize the SD card over this interface and read its configuration registers. I can easily send the read command just fine. But I don't know how to write the code to tell if the response back is success for error.</p>
  
  <p>(Sorry, no code to show. You really wanna see nothing but an ASM loop pulling bits out of a pin?)</p>