Are you using the Card Detect pin on the SD socket?
Are you using the Card Detect pin on the SD socket?
Dave
Always wear safety glasses while programming.
Hello Dave,
No I do not. Actually my schematic allows me to use it but I prefer to let the process fail and return with a fault code then ignore it because I noticed socket i use may disconnect because of a hard vibration and I do not want this to cause failure of the whole system (it did not with FAT16 library but it does with FAT32). Also I want the system keep working (with lost ability for data logging) if the card dies. I was thinking to add use of the card detect switch to save some time on timeouts in the faulty situations which I can predict and design the system that may tolerate some unpredictable errors (like died card or faulty connector). My understanding is that the sdfshc32d.pbp does not use the card detect option itself although it does configure the input pin
Thank you,
Alexey
What about something simple like
If (FAT_error != 0) Then WhatEvever
Dave
Always wear safety glasses while programming.
Hello Dave,
I learnt that the subroutine waitforcmdtimeout: cycles indefinitely when card is not there and you try to make a record, so sdfshc32d.pbp does not return control into the main code and there is no way to check FAT_error status. I may check SD_CD before writing but I suspect that the same may happen if card dies and does not respond (or connector fails which already happened to me once and this is why I started panicing) and it seems that limiting sycles to 255 helps (I checked and normally my loopcount = 2 after return, so actually only one sycle is needed and 255 is more than enough but still does not make a critical delay).
By the way, I have another strange thing here, do not know why - I have to initialize the card twice for it to work (tried many different cards, and all work only after init two times. This does not bother me too much, because it still works fine. I had the same with FAT16 library. Not sure, maybe all these things I have because my schematic does not have pull up resistors on card - perhaps need to try to add them to see if this changes something. However all works fine so far
Alexey
Last edited by Alexey; - 18th August 2012 at 10:23.
The pull-ups are a must.
As far as the 32 bit card routine not working is something I have not experienced. I use the same base code and only change the SD card include if it is a project that needs a 32 bit card.
Have you seen this?
http://www.picbasic.co.uk/forum/cont...USB-SD-LOGGING
Dave
Always wear safety glasses while programming.
Hello Dave,
Thank you,
Yes, I did see your data logger and like it very much. USB will be the next thing what I need to learn. I did not put pull up resistors on unused pins into mine, also i use micro SD and my MCU runs at 4 MHz maybe these things make me the need of initializing the card twice. After initing twice it runs fine.
Your code does not attempt to write to card when it is not inserted. Please try to insert a dummy card to see if the "include" freezes on timeout cycle or not when you write onto the card
Best regards,
Alexey
Last edited by Alexey; - 19th August 2012 at 05:59.
I just messed around with this and you are correct. There is a problem. I guess 2gb or less will have to do.
Dave
Always wear safety glasses while programming.
Bookmarks