Issue SD card with DS1307_SD-MMC_FATEngine library
JChris
Posts: 58
Hello, I try to use the DS1307_SD-MMC_FATEngine library for SD card by I don't understand why it doesn't work.
No file created.
If anyone has a hint, I would appreciate
My program is:
No file created.
If anyone has a hint, I would appreciate
My program is:
{ ************************************************************************************************************ * * * AUTO-RECOVER NOTICE: This file was automatically recovered from an earlier Propeller Tool session. * * * * ORIGINAL FOLDER: Z:\...\2. SPIN Language\Programmes a modifier - espace travail\ * * TIME AUTO-SAVED: 41 minutes ago (02/07/2014 20:53:18) * * * * OPTIONS: 1) RESTORE THIS FILE by deleting these comments and selecting File -> Save. * * The existing file in the original folder will be replaced by this one. * * * * -- OR -- * * * * 2) IGNORE THIS FILE by closing it without saving. * * This file will be discarded and the original will be left intact. * * * ************************************************************************************************************ .} { ************************************************************************************************************ * * * AUTO-RECOVER NOTICE: This file was automatically recovered from an earlier Propeller Tool session. * * * * ORIGINAL FOLDER: Z:\...\2. SPIN Language\Programmes a modifier - espace travail\ * * TIME AUTO-SAVED: 6 minutes ago (01/07/2014 23:45:55) * * * * OPTIONS: 1) RESTORE THIS FILE by deleting these comments and selecting File -> Save. * * The existing file in the original folder will be replaced by this one. * * * * -- OR -- * * * * 2) IGNORE THIS FILE by closing it without saving. * * This file will be discarded and the original will be left intact. * * * ************************************************************************************************************ .} CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 DO = 7 CLK = 5 DI = 2 CS = 1 WP = -1 CD = -1 RTCIO = -1 RTCSCLK = -1 RTCCE = -1 Var Byte coucou[50] long OK OBJ pst: "Parallax Serial Terminal" SD : "DS1307_SD-MMC_FATEngine" Pub Main microSD PUB microSD pst.Start(115200) coucou[0] := "d" coucou[1] := "a" coucou[2] := "m" coucou[3] := "i" coucou[4] := "e" coucou[5] := "n" coucou[6] := 0 OK := \SD.FATEngineStart(DO, CLK, DI, CS, WP, CD, RTCIO, RTCSCLK, RTCCE) if OK == true pst.Str(String("driver launched")) else pst.Str(String("error")) \SD.mountPartition(0) \SD.newFile(String("coucou.txt")) \SD.openFile(String("coucou.txt"), "w") \SD.writeData(@coucou, 8) \SD.readData(@coucou, 8) \SD.closeFile pst.Str(String(pst#NL,"data written"))
Comments
In the OBJ section....
Change
SD :"DS1307_SD-MMC_FATEngine"
To
SD:"SD-MMC_FATEngine"
EDIT: Additioally, remove the backslashes from the following lines
I'm inclined to agree with Bruce about using the SD driver only and not use the one with the RTC if the clock isn't being used. I don't recall if using -1 for the I2C pins is enough to eliminate the issues caused by not having a RTC.
I'm not sure why Bruce added the following:
Is there a reason you think the abort traps should be removed. IIRC, many of Kye's objects require the abort traps to work properly.
@Chris, Have you tried a simple SD demo?
Kye's SD driver is very picky about the way the SD card is formatted. I've had to reformat several SD cards (the slow way) before I could get them to work with Kye's driver.
I had previously used a uSD card to record the path taken by my PropBOE-Bot. After recording the path, the robot would repeat the path it had previous taken. I thought it was kind of cool.
To be perfectly honest, I was not thinking clearly. Just woke up
I had forgotten about RTC version
When I first looked at it, it just looked wrong. It has been such a long time since I have used an abort, I thought that occured because of the AUTO RECOVER
EDIT: Just poor advice on my part. Sorry.
@Kye did some great work to even put meaning full strings there.
so I am not sure about your first call, but usually a value >0 represents a error string address after abort in @Kyes driver.
This will give you the reason while mount failed, if it failed.
sadly this abort way collides with functions returning values. In case of an abort @Kyes driver returns the string address of the error string. Better would have been to return that address as NEGATIVE number. Easier to distinguish from NORMAL return values like number of bytes read when using readData().
But there is some method/function in @Kyes driver to check for success of the last operation. I am usually using a heavily modified version in my projects, since I always run out of space, so I do not remember the original name in @Kyes original source. getLastError()?
Look at his source. It is quite at the beginning of the PUBlic functions.
Far away from any PropTool or propeller by now, so I cant look at my sources.
Enjoy!
Mike
I haven't tried simple SD demo because I don't have it
I have an error message: Disk IO error
How can I fix this error?
Are you reformatting on a PC? Quick format does not work sometimes. What OS are you using?
Where did you find "DS1307_SD-MMC_FATEngine"? I can't locate it anywhere, or did you just rename it?
I'm with Duane. You need to archive the entire program with the Propeller Tool and post the zip.
I found "DS1307_SD-MMC_FATEngine" on OBEX (http://obex.parallax.com/object/16)SD_Card.zip
A disk i/o error means that either the electrical connection is bad or that my driver can't read the card. It's rare to run into cards that can't be read. Check your wire connections and make sure all the pins in the code are correct. A common mistake is swapping the DI and DO pins. DO is the card's data out. Not the prop chip's data out.
If you're 100% sure the electrical connections are correct then my driver may not be able to read the card. If this is the case then use a different card. If all your different cards can't be read then you likely still have an electrical connection issue.
I use a propeller C3 board and I would like to know what are pins that have to be used for activate the SD card.
I found a program but I am wondered if the _cspin and _rtcres1 are not inverted?
And I can't create a new file on the SD card, It's why if you could help me for connection of pins, I would appreciate
The program is the following:
Do you mean that your library would work with other propeller boards but not with the C3?
What's the difference. is it due to the way the SPI bus is implemented on the C3 board?
I'm sure this is the reason.
It shouldn't be too hard to modify Kye's driver to use with the C3 and there might already be a C3 friendly version available somewhere.
Haveyou tried Kye's non-RTC version first? If not, try that first.
Otherwise, if you look at the code in my PropOS (see link in m signature) and change the xtal freq (5 or 10MHz) and the PLL*16 or *8, and change the SD pins in the _hwdef.spin file, my PropOS should work using the Prop Serial Terminal connected to P30/31 (propplug to USB). You will need to recompile and then copy all the *.cmd files to the SD root directory.
If you want to tell me the xtal and sd pinouts I can compile for you and post all the files you require in the SD root directory.
I use a modified variant of Kye's FAT Engine to allow for shared SPI pins that I use on my RamBlades.
If this works, then you have proved the hardware, so its a matter of checking the SD pins to see if they are shared on the C3.
In order to save I/O pins on the C3, the chip select lines of the SPI devices are controlled with a multiplexing chip.
In general none of the normal SPI objects work on the C3 without being modified.
I just tested this on my C3 and it appears to work.
I share SPI pins on my RamBlades so I had to modify all the SD drivers to ensure the SD card released the DO pin. This involved sending some more CLKs.
I just checked my version of Kye's FAT Engine - I did not have to do this modification to Kye's driver (which IIRC was his V2).
BTW CLKFREQ is at hub $0000 and CLKMODE is at hub $0004, so my recollection above was incorrect.