uMMC_SYNC

This routine will synchronize the Basic Stamp to the uMMC. The routine sends an ASCII ESC (27 decimal, 0x1b hex) to the uMMC, which will clear its buffer and return the command prompt.

uMMC_SYNC:
  loopvar1 = 0
uMMC_SYNC_AGAIN:
  SEROUT UMMCR, uMMCBaud, [27]  ' Send an ESC to clear the buffer
  SERIN UMMCT, uMMCBaud, uMMCStartUpTimeOut, uMMC_SYNC_Error, [STR buffer\1]
  IF buffer(0) = ">" THEN GOTO uMMC_SYNC_Complete
uMMC_SYNC_Error:
  loopvar1 = loopvar1 + 1
  DEBUG "uMMC Sync Error: Bad/No response - check ST R (minimum 5)", CR
  IF loopvar1 > 3 THEN GOTO uMMC_SYNC_Error_2
  GOTO uMMC_SYNC_AGAIN
uMMC_SYNC_Error_2:
  DEBUG "uMMC Sync Error: Too many retries - check ST R, or ST D (Baud)", CR
  GOTO uMMC_SYNC_End
uMMC_SYNC_Complete:
  DEBUG "uMMC Synchronized", CR
uMMC_SYNC_End:
  RETURN

uMMCStartUpTimeOut is the amount of time (in milliseconds) that the Basic Stamp should wait before assuming there is no response. You should ensure that this time takes into consideration the amount of start up time that the uMMC may require depending on the card you use, the file system format, and the amount of files you have on the card. The amount of time can vary widely. Just watch to see how long the Activity LED on the uMMC stays on when you apply power to the uMMC.