Shop OBEX P1 Docs P2 Docs Learn Events
SD Card Issues — Parallax Forums

SD Card Issues

PhilldapillPhilldapill Posts: 1,283
edited 2009-05-24 05:35 in Propeller 1
I'm trying to get my SD Card to work with the Propeller, but I'm having some problems...

I've built my own SD Card PCB with Pull-Ups attached to all IO pins. I'm confident in the hardware itself, so that shouldn't be the issue here. I've downloaded the latest FemtoBasic object from the Obex, and I've made a simple program that I THOUGHT would be able to mount the SD Card, then open a file. I can't even get the card to mount. The program seems to hang at the point where the SD Card tries to mount. In fact, more precisely, it hangs internally at initSDCard inside mount(). What gives?

Here's the code:
CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000                                  'NOTE SPEED
  SD_DO         = 0
  SD_CLK        = 1
  SD_DI         = 2
  SD_CS         = 3
OBJ 
                                                        '1 Cog here 
  uarts         : "pcFullDuplexSerial4FC"               '1 COG for 4 serial ports
  SD            : "fsrwFemto"
  
VAR
  
Pub Start
  uarts.Init
  uarts.AddPort(0,31,30,{
}  UARTS#PINNOTUSED,UARTS#PINNOTUSED,UARTS#DEFAULTTHRESHOLD, { 
}   UARTS#NOMODE,UARTS#BAUD115200)                      
  uarts.Start                 
                          
  waitcnt(clkfreq*2 + cnt) 'Allow some time to switch to the PST

  uarts.dec(0,SD.mount(SD_DO,SD_CLK,SD_DI,SD_CS))
  uarts.str(0,string("It worked!!",13))

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-05-24 05:31
    You have to initialize the low level SD card driver by first calling

    SD.start(@ioControl) ' Start I2C/SPI driver

    where

    VAR long ioControl[noparse][[/noparse] 2 ]
  • PhilldapillPhilldapill Posts: 1,283
    edited 2009-05-24 05:35
    D'oh. Thanks Mike - works like a charm now!
Sign In or Register to comment.