SD Card Help
John Board
Posts: 371
G'day,
I've been playing around with an SD card recently and I've gotten a bit stuck - Could anyone help me?
And the output is:
[code]
Mounting...
SD was found and mounted.
Wrote 'Testing...' to test.txt
SD was found an
I've been playing around with an SD card recently and I've gotten a bit stuck - Could anyone help me?
COn _clkmode = xtal1 + pll8x _xinfreq = 10_000_000 OBJ sd : "fsrw" ser: "FullDuplexSerial" PUB Main | mount, r Ser.start(31,30,0,9600) waitcnt(clkfreq*4+cnt) ser.str(string(16, "Mounting...", 13)) mount := \sd.mount_explicit(0, 1, 2, 3) if mount < 0 ser.str(String("Mounting failed.")) abort ser.str(String("SD was found and mounted.", 13)) sd.popen(string("test.txt"), "w") sd.pputs(string("Testing...")) sd.pclose sd.unmount ser.str(String("Wrote 'Testing...' to test.txt", 13)) mount := \sd.mount_explicit(0, 1, 2, 3) if mount < 0 ser.str(String("Mounting failed.")) abort ser.str(String("SD was found and mounted.", 13)) sd.popen(string("test.txt"), "r") repeat r := sd.pgetc if r < 0 ser.str(string("EOF", 13)) reboot if r > 10 ser.tx(r) ser.tx(13) ser.str(string("Closing file and unmounting sd card.", 13)) sd.pclose sd.unmount
And the output is:
[code]
Mounting...
SD was found and mounted.
Wrote 'Testing...' to test.txt
SD was found an
Comments
-John
Although I'm still puzzled with the "\" problem
-John
like
try
catch
any abort will jump up the stack-chain until it hits a '\'. there you need to handle the error
Enjoy!
Mike
\ Abort trap: appears immediately before a method call that could potentially abort. See ABORT on page 47.
Probably it would be best to refer you to page 47 of the Propeller Manual (v1.2). There is some nice example code on pages 49-50 demonstrating use of the "\".
I see you have an abort in the program listing you posted. I'm not quite sure what that will do, because at this level there is nowhere to abort to, already the top. You could just as well use a REPEAT there to hold the program.
Comming from a computer coding background (Java, Python, etc) the "Try, Catch" analogy was something I could relate to quite easily!
-John