View previous topic :: View next topic |
Author |
Message |
Guest PIC Guest
|
Writing a text file / data to a MMC card |
Posted: Thu Sep 27, 2007 2:02 pm |
|
|
Hi,
I would like a little advice from anyone out there please!
I am trying to improve on a project I have been working on. At the current time I store 8 bits of data (256) every second into external memory via i2r. Access to this data is via rs232 / hyperterminal. I am using a 16f877 running at 20Mhz.
My idea is to store this data onto a MMC card so all I have to do for access is unplug it from the hardware and plug it in to a pc to download the data from there.
Question 1: How hard is it to create a '.txt' file using c?
Question 2: Would it be easier to create the file first and then write the data to it?
Question 3: Is SPI the best way to go (or the only way)?
I have already looked into changing my hardware - this is no problem.
I have read into this in some detail - loading 512K per write, creating a FAT32 file... and have looked on the forum at other code to do the task. However, my knowledge of c is 4/10 and I would just like to understand the bare bone to start me off.
Any help would be great, thanks!
Guest PIC |
|
|
mickent
Joined: 18 Feb 2007 Posts: 22 Location: TN, USA
|
|
Posted: Thu Sep 27, 2007 3:42 pm |
|
|
There is a good book on this subject.
USB Mass Storage by Jan Axelson
It covers MMC / SD cards as well as USB _________________ Mick |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
|
Posted: Thu Sep 27, 2007 4:02 pm |
|
|
It is far easier to use a PIC such as PIC18F4620 with 3900 bytes of memory (pin compatible with PIC16F877). This makes it easier to maintain file buffers.
SPI is the easiest way to deal with SD interfacing - it is straight forward.
The key if the flexibility of the file system driver. With the appropriate driver, you open a file and perform byte by byte writes as and when required. The file driver is responsible to maintaining and flushing file buffers at 512 byte boundaries. This is the same as if you were developing under DOS - you open a file, write to the file and close the file - you do not need to be concerned with how the driver handles the process. _________________ Regards, Andrew
http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!! |
|
|
libor
Joined: 14 Dec 2004 Posts: 288 Location: Hungary
|
|
Posted: Fri Sep 28, 2007 1:52 am |
|
|
Theoretically you can use a stripped down version of a SD driver if you use 'preformatted' media (create a single large file with the PC spanning all the card, filled with 0xFF or whatever).
All you do with the PIC is to replace the data of this file (leaving the directory and the fat table intact). You can even use less than 512 bytes of RAM in the PIC if you are willing to sacrifice the rest of the blocks' data (ther're filled with 0xFF where not used for storage, so you don't have to buffer the unused part of the blocks in RAM, just write the 0xFFs back from a loop)
...but it think it is not worth the hassle, you rather change to a bigger PIC as others advised. |
|
|
Guest 1 Guest
|
|
Posted: Tue Oct 02, 2007 6:49 am |
|
|
Quote: | Theoretically you can use a stripped down version of a SD driver if you use 'preformatted' media (create a single large file with the PC spanning all the card, filled with 0xFF or whatever). |
What a good idea. Do you think that the single large file could be a text file that was previously created via a pc? If there was a known destination, it would be possible to get the code to structure the data before it was stored. |
|
|
|