Is there any sample source code about R/W operations to SD?
Posted: Wed Dec 16, 2009 11:13 am
Is there any sample source code about Read/Write operations to SD/MMC card?
Thanks.
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Wed Dec 16, 2009 12:19 pm
Get a text search engine (or use the F3 key in Windows) and run it on
the CCS directories. Search for "SD". Set the file extensions to *.h
and *.c, and you will quickly see all files that have SD in them. Examples:
I couldn't understand exactly this source code. Where is Microcontroller writing information to text file or something like that? And what is the basic function of Read write operation? I want to write or read something in MMC from a text file. How can I do it?
I have showed the points that I couldn't understand;
Code:
do {
do {
printf("\r\nRead or Write: ");
cmd=getc();
cmd=toupper(cmd);
putc(cmd);
} while ( (cmd!='R') && (cmd!='W') );
printf("\n\rLocation: "); ////How can I determine the location?
address = gethex();
address = (address<<8)+gethex(); ////What does this code work???
if(cmd=='W') {
printf("\r\nNew value: ");
value = gethex(); //////Is "gethex()" our value to write?
printf("\n\r");
mmcsd_write_byte(address, value); //////Where is the address?
mmcsd_flush_buffer();
}
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
Posted: Sun Dec 20, 2009 2:54 pm
This code is getting Hexadecimal (0 to F) characters that you type in
from a terminal window on your PC (such as HyperTerminal or TeraTerm).
The user (you) must type in the hex numbers (and also 'W' or' R') when prompted by the program.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum