Scratching my head with this FSRW code... need some help
Don M
Posts: 1,653
I am trying to write a block of data from dat to a uSD card. I can't seem to make this work. What am I doing wrong?
Forgot to mention that this is what I see:
Edit: Added screen shot of PST
con _clkmode = xtal1 + pll16x _clkfreq = 80_000_000 MS_001 = 80_000_000 / 1_000 SD_DO = 0 ' SD card pins SD_CLK = 1 SD_DI = 2 SD_CS = 3 obj term : "fullduplexserialplus" ' for terminal output sd : "fsrw" ' SD card routines var pub main | b, i, l, m, num_bytes term.start(31, 30, %0000, 115_200) ' start terminal (use PST) pause(500) term.tx(0) ' clear screen m := \sd.mount(SD_DO) ' start sd object and mount card if m == 0 term.str(string("SD card mounted OK", 13)) else term.str(string("SD card failed to mount / not present", 13)) term.str(@version) ' display version on PST l := \sd.popen(string("test.txt"),"w") ' open file for writing on sd card called test.txt if l == 0 term.str(string("test.txt file opened", 13)) else term.str(string("File failed to open", 13)) i := 0 ' initialize index repeat i from 0 to 270 ' cycle through data and write to sd card b := \sd.pwrite(data[i], 2) term.dec(i) ' show index counter on PST term.tx(32) term.tx(13) term.dec(b) ' show number of bytes written to card term.tx(13) pause(1000) l := \sd.pclose ' close sd card file if l == 0 term.str(string("File closed", 13)) else term.str(string("File failed to close", 13)) pub pause(ms) | t t := cnt repeat ms waitcnt(t += MS_001) dat version byte "sniff_playground", 13, 0 data byte $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00 byte $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00 byte $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00 byte $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00 byte $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00 byte $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00 byte $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00 byte $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00 byte $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00 byte $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00, $0B, $0B, $00, $33, $33, $00, $10, $10, $00
Forgot to mention that this is what I see:
Edit: Added screen shot of PST
Comments
I should also mention I'm using Martins new DNA board and 2 GB sd card.
Here's my new code:
PST screen shot:
Notepad screen shot:
How do I store it as hex data? I know this may seem elementary to some but it's confusing to me sometimes....
Here's my code:
And here's what it prints out:
Any ideas?
That did it! Thanks. You're a genius! Thats what was causing it to skip over data.
Thanks again. Marking this solved.