Spudmn wrote:
And write protect will just yield errors if attempting to write, right? IE, write protect is a hardware thing isn't it?
No. The write protect switch on the SD card has no electrical connection to the card itself. The electronics in the card doesn't know if the switch is on or off and therefore wont give an error. It is up to the host to check the switch on the card socket and implement write protection.
OK, then yes, I agree with your sentiments. If there is a card, and it is FAT formatted, and there is available space, then write to it. We shouldn't format cards, though, or even have that functionality in the firmware, nor should we erase or overwrite existing files (on purpose, bugs are acceptable for a while...).
When the card starts up it waits for a bit patten before it will talk SPI mode. I was thinking that we could power cycle the card to get it in to a known state. In saying that, I don't control the power on my set up and it works fine.
Well, we can make this a generic IO pin option. Assign it to this function, and also have it optional from your code too, such taht your code knows if it has this pin or not. Such things can be hard coded for now, so wire up such a pin, and experiment, but later we won't have it.
I guess your code should have some resettable variable that says "failed to talk to card" such that if it has failed, it doesnt waste cpu time trying again without luck. you could use a byte and set the reason as a bit and just check the whole thing to see if you should try again...
Spudmn wrote:Something else to think about. User interaction.
It would be nice if the user could tell the system to stop logging and close all the files as I going to pull the card out.
Do we use a button for this?
or
will it be, turn key off. CPU detects this and closes files. Then user can pull the card. Same for start up. Turn key on and you are logging to a new file.
Yes, let people turn off the key to pull the card out, and, we can add a serial command to close files and/or start/stop logging to the card, and a configuration item in flash on whether to log to the card by default too.
Fred.