Shop OBEX P1 Docs P2 Docs Learn Events
SD program problem C3 — Parallax Forums

SD program problem C3

RsadeikaRsadeika Posts: 3,837
edited 2011-08-06 12:47 in Propeller 1
I am running into a problem with displaying the directory of the microSD card. I have a 4GB microSD card inserted, the program says it mounted the card, but it is not displaying the two *.txt files that are there. So, I am not sure as to what is going on, I reformatted the SD card to just FAT, not FAT32.

I would appreciate if somebody would look at the program and see if I missed a step, or I have some other obvious error.

Thanks

Ray
' C3_base.spin

CON
  _clkmode = xtal1 + pll16x
  _xinfreq = 5_000_000

  STATUS_LED_BUS_MUX  = 16

  CR  = 13
  LF  = 10

  spiCnt  = 8
  spiDI   = 9
  spiDO   = 10
  spiClk  = 11
  spiSel  = 5
  spiClr  = 25

  max_mount_time  = 30

OBJ
  term  : "Ext_FDSerial"
  misc  : "tools"
  fsrw  : "db_c3_fsrwFemto"

VAR
  BYTE Bytearray[15]
  long ioControl[2]
  byte tbuf[14]

PUB Start  | sds, n

''''' Blink status of C3 ''''''''''''''
  DIRA[STATUS_LED_BUS_MUX] := 1
  OUTA[STATUS_LED_BUS_MUX] := 0

  repeat 3
    OUTA[STATUS_LED_BUS_MUX] := 1
    misc.waitMS(500)
    OUTA[STATUS_LED_BUS_MUX] := 0
    misc.waitMS(500)
'''''''''''''''''''''''''''''''''''''''


  
''''' C3 port B '''''''''''''''Rx Tx ''
'''' Start serial port on pins 22,23 ''
  misc.waitMS(250)
  term.Start(22,23,0,115200)
'''''''''''''''''''''''''''''''''''''''

''''' Start the SD driver '''''''''''''
  fsrw.start(@ioControl)
  misc.waitMS(250)
  repeat n from 0 to max_mount_time
    sds := \fsrw.mount(spiSel,spiClr,spiCnt,spiDI,spiDO,spiClk)
    if sds > -1
      quit
  if sds < 0
   term.str(string("SD is mounted.",CR,LF))
  else
   term.str(string("SD is NOT mounted.",CR,LF))

    
  fsrw.opendir
  repeat while fsrw.nextfile(@tbuf) == 0
    term.str(@tbuf)
    term.tx(CR)
    term.tx(LF)
  if fsrw.nextfile(@tbuf) == -1
   term.str(string("No files found",CR,LF))

 

  Main

PUB Main | new_byte


  repeat
    new_byte:= term.rx
    if new_byte == CR     ' Hit CR to make terminal live
      term.str(string("This is the C3 basic setup",CR,LF))
      repeat
        term.str(string(">"))
          repeat
             term.rxstr(@Bytearray)
          while Bytearray == -1
         if strcomp(@Bytearray,@lite1on)
           LED1on
         elseif strcomp(@Bytearray,@lite1off)
           LED1off
         else
            term.str(string("No such command",CR,LF))


PUB LED1on
  misc.high(19)

PUB LED1off
  misc.low(19)


DAT

lite1on  byte "lite1on",0
lite1off byte "lite1off",0


Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2011-08-06 10:38
    Hi Ray,

    did you run the testprogram "c3_sd_demo_010.spin" that does check the SD-card?

    Th test-prg requires a PS/"-keyboard connected to the C3 and a terminal-prg like PST.EXE running

    This file says in the comments
    7. Remember, ALWAYS format your SD cards FAT16, and make sure you do NOT use
    folders and all your file names are ALWAYS 8.3. Also, its suggested that you
    use 1-2G SD cards, these seem to work the best.

    If I remember right 2GB is the maximum the existing drivers can handle.
    Did you try another SD-gard with 1 or 2GB

    keep the questions coming
    best regards

    Stefan
  • RsadeikaRsadeika Posts: 3,837
    edited 2011-08-06 11:30
    I borrowed the db_C3_fsrwfemto.spin, and db_C3_sdspi.femto.spin from the Music Box by William Chan. I want to use a driver(s) that is more straight forward than the standard C3 driver. I am trying to test out the use of the SD card, SRAM, and flash ram with a system that uses a serial port with a custom terminal program.

    I only had one 2GB SD card that turned out to be bad, so I thought I would give a 4GB SD card a try. Maybe the original author should think about adding some idiot proofing in the program, so people like me would be warned. Thinking about the 2GB limit, if there really is one, is it a hardware or software problem? The one thing I did notice when I run my program it takes an awful long time for the SD card to get initialized.

    I guess I need more suggestions as to what should be the next step, besides putting in a 2GB SD card, I have those on order.
  • LeonLeon Posts: 7,620
    edited 2011-08-06 12:12
    I've used the FSRW software with an SD card without any problems.
  • RsadeikaRsadeika Posts: 3,837
    edited 2011-08-06 12:47
    I used the plain FSRW on another project, and it worked as expected. Now that I have worked with the C3, I wish that the SD would have been connected to p0 - p3, then I could of used the plain FSRW driver. The question still remains, is their really a 2GB limit on the SD card use when using any of the SD card drivers?
Sign In or Register to comment.