Problem Interfacing micro SD card with Propeller
Hey everybody,
I am trying to interface with multiple modules: GPS, LCD, XBee, and micro SD. I have successfully communicated with all of the components, but the SD card refuses to reliably write files. I can write a program that writes successfully to the card, but a seemingly benign change will cause written files to be corrupted (the titles of the files are non-ascii characters and the computer can't open them). I constructed a rudimentary program that reproduces the problem.
As posted, the following code wrote all three files successfully. However, if I un-commented the GPU.start_GPS line, the third file is corrupted. The intermittent delays is me trying to reproduce this behavior. I have checked my wiring, and I am pretty sure it is correct. Again, I have successfully interfaced with all modules, so I don't think it is hardware. Also, I am using version 2.6 of the "fsrw.spin" file.
Could it be the way I formatted the SD card? Any help would be greatly appreciated.
micro SD card INFO:
16GB
formatted using Windows VISTA (FAT32, allocation size = 16kb)
The start_GPS method is posted below:
I am trying to interface with multiple modules: GPS, LCD, XBee, and micro SD. I have successfully communicated with all of the components, but the SD card refuses to reliably write files. I can write a program that writes successfully to the card, but a seemingly benign change will cause written files to be corrupted (the titles of the files are non-ascii characters and the computer can't open them). I constructed a rudimentary program that reproduces the problem.
As posted, the following code wrote all three files successfully. However, if I un-commented the GPU.start_GPS line, the third file is corrupted. The intermittent delays is me trying to reproduce this behavior. I have checked my wiring, and I am pretty sure it is correct. Again, I have successfully interfaced with all modules, so I don't think it is hardware. Also, I am using version 2.6 of the "fsrw.spin" file.
Could it be the way I formatted the SD card? Any help would be greatly appreciated.
micro SD card INFO:
16GB
formatted using Windows VISTA (FAT32, allocation size = 16kb)
con
_xinfreq = 5_000_000
_clkmode = xtal1 + pll16x
LCD_pin = 27
SD_pin = 0
Prop2GPS_Rx = 24
Prop2GPS_Tx = 25
Var
byte message1[20]
byte message2[20]
byte sdready
byte filename[20]
OBJ
lcd : "Serial_Lcd"
delay : "Timing"
sdfat : "fsrw"
GPU : "gps_utils"
PUB main
'GPU.start_GPS(Prop2GPS_Rx, Prop2GPS_Tx, 0, 4800)
lcd.start(LCD_pin, 19200, 4)
lcd.cls
delay.pause1ms(100)
message1 := string("please work")
message2 := string("another message")
' mount SD card
sdready := sdfat.mount(SD_pin)
lcd.str(message1)
'' write first file
filename := string("file_a6.txt")
sdfat.popen(filename, "w")
sdfat.pwrite(message1,10)
delay.pause1ms(10)
sdfat.pwrite(message2,10)
sdfat.pputc(65)
sdfat.pclose
filename := string("file_b6.txt")
sdfat.popen(filename, "w")
sdfat.pwrite(message2,10)
sdfat.pclose
delay.pause1ms(1000)
filename := string("file_c6.txt")
sdfat.popen(filename, "w")
sdfat.pwrite(message2,10)
sdfat.pclose
delay.pause1ms(1000)
The start_GPS method is posted below:
PUB start_GPS (PropRx_pin, PropTx_pin, mode, baud)
cog_used := uart.start(PropRx_pin, PropTx_pin, mode, baud)
Comments
Your test program will work if you declare message1, message2 and filename as word or long variables.