Please post your comments on Spudmn's thread in this one. His thread, which you should not post in, is here:
Start: viewtopic.php?f=8&t=1073
Unread/Latest: viewtopic.php?f=8&t=1073&view=unread#unread
Fred.
SD Card and FAT FS for FreeEMS - COMMENTS
SD Card and FAT FS for FreeEMS - COMMENTS
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
Re: SD Card and FAT FS for FreeEMS - COMMENTS
Is a GPIO pin sufficient, or does it need to be more than "bit on/bit off" ? If GPIO is fine, there are many spares on the header.Spudmn wrote:The SPI pins MISO, MOSI, SCK are available on connector P71 but I still need a Chip select. <snip> I need to find CS from some where.
Card detect we can do by lack of response, right? And write protect will just yield errors if attempting to write, right? IE, write protect is a hardware thing isn't it?Do we want to worry about the Card detect switch and the write protect switch?
And that too! :-)and if you have a card plugged into your Puma then I think that you should expect data to be written to it.
I don't see the benefit in this. If the ignition is on, and we power it from that part of the supply (will be split later) then it's minimal draw, and if not being written to, it does no harm. Can you explain why you'd want to do that? I can't see it.It might be a good idea to be able to control the power to the SD card, so that may be another pin we will need.
Fred.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
- Spudmn
- LQFP112 - Up with the play
- Posts: 232
- Joined: Thu Feb 10, 2011 12:27 am
- Location: Auckland, NZ
Re: SD Card and FAT FS for FreeEMS - COMMENTS
GPIO will be fineFred wrote: Is a GPIO pin sufficient, or does it need to be more than "bit on/bit off" ? If GPIO is fine, there are many spares on the header.
Yes, as long as the card doesn't lock up and need a power cycle. see belowCard detect we can do by lack of response, right?
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.And write protect will just yield errors if attempting to write, right? IE, write protect is a hardware thing isn't it?
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.I don't see the benefit in this. If the ignition is on, and we power it from that part of the supply (will be split later) then it's minimal draw, and if not being written to, it does no harm. Can you explain why you'd want to do that? I can't see it.
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.
Aaron
-
- QFP80 - Contributor
- Posts: 62
- Joined: Thu Oct 30, 2008 10:35 am
- Location: Benschop, Netherlands
Re: SD Card and FAT FS for FreeEMS - COMMENTS
I think using the SPI bus for this purpose is going to be easier, faster and less CPU intensive.
And SPI is a bus so you do not have to completely offer the SPI bus of the microcontroller, the only thing you would need is a GPIO chip select per SPI device
I also think that controlling the power for the SD card from the microcontroller is a good idea
And SPI is a bus so you do not have to completely offer the SPI bus of the microcontroller, the only thing you would need is a GPIO chip select per SPI device
I also think that controlling the power for the SD card from the microcontroller is a good idea
Re: SD Card and FAT FS for FreeEMS - COMMENTS
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...).Spudmn wrote: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.And write protect will just yield errors if attempting to write, right? IE, write protect is a hardware thing isn't it?
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.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.
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...
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.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.
Fred.
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
Re: SD Card and FAT FS for FreeEMS - COMMENTS
Maybe we could have formatting cards as an option but ONLY linked to a serial command, not autonomously, ever :-)
DIYEFI.org - where Open Source means Open Source, and Free means Freedom
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
FreeEMS.org - the open source engine management system
FreeEMS dev diary and its comments thread and my turbo truck!
n00bs, do NOT PM or email tech questions! Use the forum!
The ever growing list of FreeEMS success stories!
Re: SD Card and FAT FS for FreeEMS - COMMENTS
Any chance the SPI Slave Select expander could be put to use here? There is the /SS -pin (Slave Select) unused on the MCU sheet which is *the* pin for Chip Select but with just one you aren't going to do much.