Hello,
I would like some assistance with storing information on a SD card in the format of a text file. This SD card is connected to a 8051 microcontroller. Communication with the card is done via the SPI. I'd really appreciate some sort of #include file or anything that lets me have access to functions such as fprintf and fscanf, fopen, fclose. Also if anyone can tell me weather FATfs (elm-chan.org/.../00index_e.html) files are ok to compile on a 8051.
IF you look at the bottom of that page, you will see that it's been done for AVRs - so I see no reason why it shouldn't be doable on a suitable 8051.
The files are there and free for you to download - so why not just try it for yourself?
I've tried compiling ff.c and it says "ERROR C200 IN LINE 1901 OF ff.c : maximum object size reached (8192 bytes)". Also I really would appreciate a step by step guide (IE 1.Get SPI working, 2. FAT32 essential files etc) if possible. I'm new with this and I really do not understand some of the functions in ff.c and how they interact with the SD card (for example if I can simply add my own code to ff.c and use the defined functions without other complications, aside from port assignment maybe.)
What says that?
According to the online manual, that is not the text for Keil C51 Error C200:
http://www.keil.com/support/man/docs/c51/c51_c200.htm
What 'Object' is it referring to?
"I really would appreciate a step by step guide"
Have you studied all the reference materials at elm-chan.org/.../00index_e.html ?
It is a pretty widely-used piece of software - lots to find with google...
For specific questions about FatFs, have you tried asking on the FatFs forum?
"I'm new with this"
New to what, exactly?
This thread can now be closed I guess, as there really seems to be nobody that provides useful information. You ask me "new to what exactly" when I clearly explain what I have difficulties with ("I really do not understand some of the functions in ff.c and how they interact with the SD card (for example if I can simply add my own code to ff.c and use the defined functions without other complications, aside from port assignment maybe.)").
I do not understand how many of the functions included in ff.c are useful for simply creating and appending a string of characters to a file. I do not care about anything else other than being able to create a windows (xp, 7, vista whatever) recognizable file with an 8051 on a SD card.
My goal would be measuring some data for an extended period of time with the 8051 on the SD card, after which I would copy that data to my PC for further use. The PC and 8051 cannot be connected for most of the time (save maybe 30 mins per month), so I had to think of some way of saving a month's worth of data, and this is the first thing I thought about.
I would appreciate if someone who actually had to create some sort of "movable medium" (larger than 1MB) between a PC and 8051 offered insight. Otherwise just close the topic please and I'll try to figure it out.
The purpose of this forum is to discuss Keil tools & products - not to give free consultancy.
See: http://www.keil.com/forum/
If you want a consultant to help you with your project, try: http://www.keil.com/condb.
"You ask me 'new to what exactly'"
That is a perfectly reasonable question. Remember that nobody knows anything about you or your experience other than what you clearly and explicitly state in your posts.
In particular, we don't know if you are: new to any form of programming; new to the 'C' language; new to embedded systems; new to the 8051; new to dealing with file systems; etc, etc,...
"I clearly explain what I have difficulties with ("I really do not understand some of the functions in ff.c and how they interact with the SD card (for example if I can simply add my own code to ff.c and use the defined functions without other complications, aside from port assignment maybe.)"
No, that is not clear at all!
"I do not understand how many of the functions included in ff.c are useful..."
You keep saying you don't understand, but you have given no indication of having read any of the documentation at elm-chan.org/.../00index_e.html Each of the functions has a page documenting it, and many examples are available both on that site and elsewhere on the interweb.
" I do not care about anything else other than being able to create a windows (xp, 7, vista whatever) recognizable file with an 8051 on a SD card."
Clearly, a general-purpose library such as FatFs is going to contain more stuff than is going to be needed for any one specific task. Don't worry about it!
"I would appreciate if someone who actually had to create some sort of "movable medium" (larger than 1MB) between a PC and 8051 offered insight"
You should be able to find examples on the web; if you want someone to dedicate time specifically to doing it for you, that's a consultancy job.
Note that there are many low-cost development boards that come complete with an SD-Card socket & examples. If you want something "ready-to-go", that might be your best option...
It may sound trivial to append data to a text file.
But you need to load the information telling what file system type you have. And you need to locate the root directory. And you need to locate individual FAT chains in the FAT tables. And you need to find free clusters to append to the FAT chain whenever the file grows enough that the already mapped clusters are not enough for the new data.
And the need to write back the appended information. And the FAT chain changes. And any changes to the directory entry/entries involved.
Suddenly, you need quite a number of functions. You might be able to find "end-user" functions for mkdir/rmdir/delete/rename/... that you may be able to remove. But the large bulk of functions performs low-level operations that you normally never have to think about when your PC accesses and updates files on a floppy or a memory card or the HDD.
Thanks for your replies. It seems that being able to create PC recognizable files with the 8051 is really a lot of work. I'll get to it and maybe look into alternatives (loading data to PC via UART from time to time would be a viable option, but I really don't know if the 8051 has enough memory of it's own to save the 1000+ measurements I take during a month's time).
It's possible to store data on a memory card, EEPROM, ... without the use of any file system.
But then it is up to you to figure out how much area you have filled, so you know where to continue adding data.
For memory cards, the controller inside the card normally handles wear leveling. But you have to take care of any problems with power losses when you are busy writing data.
View all questions in Keil forum