CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Is there any sample source code about R/W operations to SD?

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
theasus



Joined: 31 May 2009
Posts: 79

View user's profile Send private message

Is there any sample source code about R/W operations to SD?
PostPosted: Wed Dec 16, 2009 11:13 am     Reply with quote

Is there any sample source code about Read/Write operations to SD/MMC card?


Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Wed Dec 16, 2009 12:19 pm     Reply with quote

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:
Quote:

c:\program files\picc\examples\ex_mmcsd.c
c:\program files\picc\examples\ex_fat.c

Also look in the CCS code library forum.
theasus



Joined: 31 May 2009
Posts: 79

View user's profile Send private message

PostPosted: Sun Dec 20, 2009 6:08 am     Reply with quote

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=='R')
      { 
         mmcsd_read_byte(address, &value);
         printf("\r\nValue: %X\r\n", value);
      }

      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

View user's profile Send private message

PostPosted: Sun Dec 20, 2009 2:54 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group