• AVR Freaks

SPI and MMC

Page: < 123 Showing page 3 of 3
Author
jsluke
Starting Member
  • Total Posts : 69
  • Reward points : 0
  • Joined: 2010/11/05 09:24:51
  • Location: 0
  • Status: offline
Re:SPI and MMC 2011/02/05 12:11:50 (permalink)
0

I've been working through this in slow time using the MPLAB debugger.

I can see two issues:

  1. throughout the initialisation sequence, DO on the SD-Card is low - the detail on this site => http://www.esawdust.com/blog/serial/files/SPI_SD_MMC_ATMega128_AVR.html states that DO (MISO) should be high and go low 16 clocks after the initial sequence was sent.  I've trawled through a series of discussions on the use of pull ups and pull downs (e.g. http://www.microchip.com/forums/m419087-print.aspx and http://www.microchip.com/forums/tm.aspx?m=148739).  There are lots of different opinions on this subject (and best practice may depend on the card in use) so I've tried adding a 10K pull up resistor to DO / MISO.
  2. however, whilst testing to see if this worked I ran into a second issue.  When stepping through the code using the MPLAB debugger the idle command (required as part of the initialisation sequence) does not seem to get sent.  The debug code pointer reaches the line where the command is called - response = SendMMCCmdManual (GO_IDLE_STATE, 0x0 ); - into the MDD_SDSPI_MediaDetect function.  The library code includes a lot of conditional compile macros, however I can't see any reason for the program pointer to jump like this.  I've posted a separate question on this subject to the MPLAB IDE Forum ( http://www.microchip.com/forums/tm.aspx?tree=true&m=555219 ).
I believe that fixing (2) above is the priority.

The initialisation sequence isn't being completed in that the GO_IDLE_STATE command is never sent.  I am now trying to understand whether any of the configuration parameters (e.g. MEDIA_SOFT_DETECT ) could be causing this problem.

Thanks.

James.
#41
jsluke
Starting Member
  • Total Posts : 69
  • Reward points : 0
  • Joined: 2010/11/05 09:24:51
  • Location: 0
  • Status: offline
Re:SPI and MMC 2011/02/10 12:25:39 (permalink)
0

The latest on this is that I've made more progress (but still not quite there).

I overcame the debug issue by switching off the compiler optimisation - something I should have thought about initially.

I then spent a huge amount of effort trying to understand why my SD Card was not responding to the activation sequence.  After a good deal of probing I discovered a problem with the SD Card breakout board I was using.  There was an issue with the connectivity of the MISO board - nothing wrong with my wiring - I only discovered when I actually put a probe almost directly onto the card to see that it was actually responding.

So, the current status is that the board completes most of the initialisation sequence.  MDD_SDSPI_MediaInitialize progresses all the way to the instruction to the very last card call =>

for (timeout=0xFF; timeout > 0 && MDD_SDSPI_SectorRead(0x0, NULL) != TRUE; timeout--)
{;}
This call appears to timeout with MDD_SDSPI_SectorRead only ever returning FALSE.

The status is set to FALSE in MDD_SDSPI_SectorRead because =>
data_token != DATA_START_TOKEN

So close but not quite there.

Thanks.

James.
#42
Page: < 123 Showing page 3 of 3
Jump to:
© 2019 APG vNext Commercial Version 4.5