SDcard and Propeller
rkrasowski
Posts: 16
Hello,
I am trying to create log, that will be logging temperature, pressure, GPS data etc. Plan is to send data to main computer using XBee as well as record it into SD card connected with Propeller.
Sadly I have a problem at the beginig of working with SDcard. I am using following code:
"
OBJ
sdfat : "fsrw"
db : "FullDuplexSerial"
PUB main | gmt, r
db.start(31,30,0,9600)
db.str(string(13,"Will try to mount SDCard",13))
if \sdfat.mount(3) <> 0
db.str(string(13,"Failed to mount SD"))
sdmounted := 0
else
sdmounted := 1
db.str(string("Mounted.", 13))
"
and I can not mount the card, I am getting message "Failed to mount SD".
I am using Propeller Demo board with micro-SD Card Adapter. My SD card has 2Gb and is formatted in FAT16. My base code is from book "programming and customizing the multicore propeller microcontroller". Source code : ftp://ftp.propeller-chip.com/PCMProp/Chapter_09/Source/
My SDcard connect:
P0 - DO
P1 - CLK
P2 - DI
P3 - CS
What is the problem??
Thanks in advance
Robert
I am trying to create log, that will be logging temperature, pressure, GPS data etc. Plan is to send data to main computer using XBee as well as record it into SD card connected with Propeller.
Sadly I have a problem at the beginig of working with SDcard. I am using following code:
"
OBJ
sdfat : "fsrw"
db : "FullDuplexSerial"
PUB main | gmt, r
db.start(31,30,0,9600)
db.str(string(13,"Will try to mount SDCard",13))
if \sdfat.mount(3) <> 0
db.str(string(13,"Failed to mount SD"))
sdmounted := 0
else
sdmounted := 1
db.str(string("Mounted.", 13))
"
and I can not mount the card, I am getting message "Failed to mount SD".
I am using Propeller Demo board with micro-SD Card Adapter. My SD card has 2Gb and is formatted in FAT16. My base code is from book "programming and customizing the multicore propeller microcontroller". Source code : ftp://ftp.propeller-chip.com/PCMProp/Chapter_09/Source/
My SDcard connect:
P0 - DO
P1 - CLK
P2 - DI
P3 - CS
What is the problem??
Thanks in advance
Robert
Comments
thanks like always
Well even before I tried " if \sdfat.mount(0) <> 0"
No luck, still can not mount
Any ideas??
Robert
In the future, please use the [ CODE ] and [ /CODE ] brackets around your code. Cutting and pasting causes your code formatting to be lost. With Spin, it's impossible to tell how your program works unless you use the brackets.
I upgraded to new ver of FSRW (2.6) and now it works !!!
Thanks Mike again
Robert
I am making progress with my project, now I am stuck on adding data into the file on SDcard. Now everytime propeller is power on , starts routine and start writting ( and erasing data) into the same file, I am sure there is a method for writting, reading and adding.
Is it insteed of:
sdfat.popen(string("newfilexr.txt"), "r") - writting
sdfat.popen(string("newfilexr.txt"), "a") - adding
just guessing, I have not tested this yet.
Robert
Kye's SD routines aren't too much different in the way they handle. If you can do fsrw, you can handle the switch.
OBC
I am analizing all methods and I do not see method to put decimal value into the SDcard. Old ver had something like SDStr, SDdec, SDhex. Ver 2.6 does not have it. I see pputs ( i uderstand this is for string)
I see pputc, but how do I write dec value??
Thanks like always
Robert
Here is the code if anyone needs it:
[
PUB SDdec(value) | i
if value < 0
-value
pputc("-")
i := 1_000_000_000
repeat 10
if value => i
pputc(value / i + "0")
value //= i
result~~
elseif result or i == 1
pputc("0")
i /= 10
]
also answering my previous question, FSRW can add data to file. Here is the code to open file for adding :
[
sdfat.popen(string("newfilexr.txt"), "a")
]
Thanks again for yopur help.
Robert