FSRW fast start for dummies (like me)
StevenR
Posts: 13
I'll be wiring up my uSD board next week and have read the readme's but would like a jump start into reading and writing to an SD card.
Would someone post some code that shows basic functions like how to initialize FSRW, mount the card, read/writes to the card, file naming, file retrieving, etc.
Tnx.
Would someone post some code that shows basic functions like how to initialize FSRW, mount the card, read/writes to the card, file naming, file retrieving, etc.
Tnx.
Comments
From another dummy (me) here is some code I wrote to test my uSD unit too.
It creates a file and writes some·numbers (longs, bytes and words)·to it in Binary
and in Text format and writes some text strings too.
Then it also reads the file back and prints the read stuff to the PST.
All the time it is also reporting to the PST what it is doing.
The code is largely self commenting and should be easy to understand.
I am using the FSRW_23 object....there is now a 26 version but it should
not be any different.
I hope this helps.
Read the code before you run it.... when you run it you need to press Enter on the PST to start the action.
This is made clear when you study the code.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Samuel
www.RobotBASIC.com
Thank you very much for posting your code. I went through it along with the FSRW object and it is making sense to me.
I've begun to write my code in anticipation of getting the uSD board next week.
I do have one question, what is the difference between "mount_explicit" and "mount"?
My board already uses P0 so I will be using P1 as the first pin for the SD board. I think that I read somewhere in the forum that if I deviate from using P0 as the first pin then I have to do something different with the mount command.
Steven.
I am glad you found my code useful. If you change the BASE pin to P1 or whatever then just
change the Orange line in the code below to say so.
Remember this is the BASE pin and so you will then need to connect D0 to that base pin and
SCLK to BasePin+1, DI to BasePin+2, CS to BasePin+3
The code I wrote does not make use of the Card_Detect pin (CD) this you can connect to any
pin you like it does not have to be sequential. But the FSWR object does not make use of it, nor
does my code.
It provides·a·means for detecting if there is a card inserted in the holder or not. This can be useful
to avoid doing the mounting which will fail if there is no card.
As far as Mount_Explicit() and Mount() have a look at the descriptions in the code below
With Mount_Explicit() you specify what pin number you want for each of the D0,SCLK,DI and CS
so they do not have to be CONSECUTIVE....they can be ANY pins.
With Mount() you specify the BASE PIN ie the D0 pin but then it is assumed that the SCLK, DI and CS are
then the CONSECUTIVE pins as described above.
So it is up to you which you want to use but in fact Mount() calls Mount_Explicit() any way notice
how it does it below. You can change my code to use the Mount_Explicit() instead of Mount() and then
pass it the appropriate pin numbers, but the rest of the code would be no different.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Samuel
www.RobotBASIC.com
Post Edited (SamMishal) : 1/2/2010 6:21:51 AM GMT
Got the board wired this morning (Sat).
Your code works great and am implementing parts of it in my application.
Thanks again.
Steven.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Samuel
www.RobotBASIC.com
·