Basic SD Card Format Writing
Hello,
I am trying to write a variable to a file on an SD card, but I don't know how! I understand the basics of writing to an SD card, but mainly strings. I am using the fsrw object. Below is my code.......I have put a comment in indicating where my problem is.....it's only 1 line! Any help would be greatly appreciated. Thanks.
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
DO = 10
CLK = 11
DI = 12
CS = 13
OBJ
sd : "fsrw"
pst: "parallax serial terminal"
PUB main | mount, x
pst.start(38400)
waitcnt(160_000_000 + cnt)
mount := \sd.mount_explicit(DO, CLK, DI, CS)
if mount <= 0
pst.str(string("Failed to mount", 13))
abort
pst.str(string("mounted", 13))
sd.popen(string("data.csv"), "a")
sd.pputs(string("variable", 13))
x := 0
repeat 4
pst.dec(x)
pst.str(string(13))
sd.pputs() '<
what do I put here??????
sd.pputs(string(13))
x++
waitcnt(40_000_000 + cnt)
sd.pclose
sd.unmount
pst.str(string("Safe to remove.", 13))
I am trying to write a variable to a file on an SD card, but I don't know how! I understand the basics of writing to an SD card, but mainly strings. I am using the fsrw object. Below is my code.......I have put a comment in indicating where my problem is.....it's only 1 line! Any help would be greatly appreciated. Thanks.
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
DO = 10
CLK = 11
DI = 12
CS = 13
OBJ
sd : "fsrw"
pst: "parallax serial terminal"
PUB main | mount, x
pst.start(38400)
waitcnt(160_000_000 + cnt)
mount := \sd.mount_explicit(DO, CLK, DI, CS)
if mount <= 0
pst.str(string("Failed to mount", 13))
abort
pst.str(string("mounted", 13))
sd.popen(string("data.csv"), "a")
sd.pputs(string("variable", 13))
x := 0
repeat 4
pst.dec(x)
pst.str(string(13))
sd.pputs() '<
what do I put here??????
sd.pputs(string(13))
x++
waitcnt(40_000_000 + cnt)
sd.pclose
sd.unmount
pst.str(string("Safe to remove.", 13))