Shop OBEX P1 Docs P2 Docs Learn Events
Issue with mounting of SD card — Parallax Forums

Issue with mounting of SD card

JChrisJChris Posts: 58
edited 2014-08-02 03:59 in General Discussion
Hello, I am trying to save data into SD card but I have an issue with mounting of SD card.
I have formatted my micro SD card in FAT16 and FAT32 (
with a software and also directly with the computer) and I have the following program but I don't understand why my SD card do not mount :

CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000

PC_Rx = 31
PC_Tx = 30
PC_Baud = 115200


TX_PIN = 4
BAUD = 9600


DO = 0
CLK = 1
DI = 2
CS = 3
WP = -1
CD = -1
RTCIO = -1
RTCSCLK = -1
RTCCE = -1



Var
long data[50], donnee[10]
long OK, mount

OBJ
PC : "FullDuplexSerial"
LCD : "FullDuplexSerial"
SD : "DS1302_SD-MMC_FATEngine"


Pub Main

LCD.start(TX_PIN, TX_PIN, 0, BAUD)
waitcnt(clkfreq / 100 + cnt)
LCD.tx(12)
waitcnt(clkfreq + cnt)
LCD.tx(17)
waitcnt(clkfreq + cnt)


microSD


PUB microSD


OK := \SD.FATEngineStart(DO, CLK, DI, CS, WP, CD, RTCIO, RTCSCLK, RTCCE)
if OK == true
LCD.Str(String("driver launched"))
else
LCD.Str(String("error"))

mount := \SD.mountPartition(0)


if mount == false
LCD.Str(String("SD card mounted"))
else
LCD.Str(String("SD card not mounted"))


SD.openFile("coucou", "w")


SD.writeString(@donnee)


Any help would be appreciated

Comments

  • ElectrodudeElectrodude Posts: 1,658
    edited 2014-07-28 14:37
    attachment.php?attachmentid=78421&d=1297987572


    The documentation for the SD.mountPartition method says:
    Returns true if the partition was improperly unmounted the last time it was mounted and false if not.
    If an error occurs this method will abort and return a pointer to a string describing that error.

    I think the partition is being mounted correctly and that you are misinterpreting the return code. If the partition was properly mounted this time but improperly unmounted last time, this method will return true. Don't assume failure if it returns true - only assume failure if it returns something other than true or false, such as a pointer to a string describing the error (which you can print onto your debug terminal).
  • JChrisJChris Posts: 58
    edited 2014-07-30 09:44
    I have a code that is returned (3192) but I don't know what it means. Is there a file that give error codes?
    And if yes, where I can find it?
  • ElectrodudeElectrodude Posts: 1,658
    edited 2014-07-30 10:34
    3192 seems reasonable. Print it out as if it were a pointer to a string (because it is). The code probably changes every time you edit your code, so don't rely on it staying the same.
    PC.str(mount) ' was 3192 but will change after you add this line (but will still have the same meaning)
    
  • JChrisJChris Posts: 58
    edited 2014-08-02 03:59
    My error is: Disk IO Error.

    So I have formatted my micro SD card with my computer and fixed the Disk.
    I don't find any clue on Internet for fixed my problem.
    Have you got an idea of the problem?
Sign In or Register to comment.