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

SD Card Memory Address Location using mmcsd.c PLEASE HELP!

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



Joined: 08 Apr 2010
Posts: 13

View user's profile Send private message

SD Card Memory Address Location using mmcsd.c PLEASE HELP!
PostPosted: Sat Apr 17, 2010 2:32 pm     Reply with quote

Hi Everyone,

I've been successful in modifying ex_mmcsd.c file to write data to memory location 0x1000 and 0x1001 and displaying it on a 16x2 LCD display.

My goal is to set aside each block (512bytes) for logging data (body weight) for individuals (ID). I know I have no choice but to set aside block size to be 512 bytes even though I only need to use about 16bytes to keep track of individuals' info.

I've been having trouble trying to figure out how memory addressing works in SD. I've looked at the manual and everything, but I am not sure how to partition each block as in I don't know when one block starts and ends and etc. MikroC compiler has a command where you can write to each sector by just naming a sector by a number; for example mmmc_write_sector(10, data). In MMCSD.C , you can write to a block, but it appears that you have to have a specific address such as 0x1000, which means if that is where the block starts, all 512bytes after 0x1000 constitutes that one block.

My problem is that I don't know where blocks start. Anybody have any suggestions? Thanks
curiousaboutcircuits85



Joined: 08 Apr 2010
Posts: 13

View user's profile Send private message

PostPosted: Sat Apr 17, 2010 2:33 pm     Reply with quote

Also, I am using PIC18f4520 and a 2GB SanDisk SD Card.
asmallri



Joined: 12 Aug 2004
Posts: 1634
Location: Perth, Australia

View user's profile Send private message Send e-mail Visit poster's website

Re: SD Card Memory Address Location using mmcsd.c PLEASE HEL
PostPosted: Sat Apr 17, 2010 10:04 pm     Reply with quote

curiousaboutcircuits85 wrote:
Hi Everyone,

I've been successful in modifying ex_mmcsd.c file to write data to memory location 0x1000 and 0x1001...

My goal is to set aside each block (512bytes) for logging data (body weight) for individuals (ID). I know I have no choice but to set aside block size to be 512 bytes even though I only need to use about 16bytes to keep track of individuals' info.

....

In MMCSD.C , you can write to a block, but it appears that you have to have a specific address such as 0x1000, which means if that is where the block starts, all 512bytes after 0x1000 constitutes that one block.

My problem is that I don't know where blocks start. Anybody have any suggestions? Thanks



Blocks start (not surprisingly) on 512 byte boundaries. If you are using the media as raw storage and therefore not using a file system. You can write starting on any 512 byte boundary.
_________________
Regards, Andrew

http://www.brushelectronics.com/software
Home of Ethernet, SD card and Encrypted Serial Bootloaders for PICs!!
curiousaboutcircuits85



Joined: 08 Apr 2010
Posts: 13

View user's profile Send private message

PostPosted: Sun Apr 18, 2010 2:16 am     Reply with quote

Thank you for your reply. Does that mean that I could think of block number one being from address 0 through 511 and block number two from address 512 to 1024?

Also, I was hoping that somebody could clarify for me what RCA register is. The datasheet says that it represents 16bit address, but it also mentions address for bytes being 32 bits. If I have 2GB SD card, does anyone have an idea of how many writeable byte address there is? Thanks
gopalakrishnan



Joined: 18 Jun 2010
Posts: 25

View user's profile Send private message

regarding sd card
PostPosted: Tue Nov 09, 2010 11:28 pm     Reply with quote

I am trying the same project for past three months.

http://www.ccsinfo.com/forum/viewtopic.php?p=140016#140016

You can see my code in the above mentioned link. Kindly see the code at the bottom.

I am unsuccessful in my attempt. Kindly help me out of the problem. How you acheive this and what wrong I did in my program.

with regards
k.gopalakrishnan
gopal_kmu54@hotmail.com
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Wed Nov 10, 2010 4:06 pm     Reply with quote

MMC cards use byte addressing. They attempt to mimic memory as far as reads go. On writes to update a byte you have to read in the block( 512 bytes) it resides in make the change and write the whole block out, It is still byte addressing just that you need the starting byte address of the containing block.

SD cards use block addressing. They attempt to mimic hard drives. The block is 512 bytes
Suppose you want byte 520 for MMC the address is 520 but for SD it's block 1 and 8 bytes in. A MMC card is limited to a 4 gb 32 bit address
A sd card is limited to presumably 4x512 gb ( I'm not sure of this a disk has 28 bit address so not all the 32 bits are used if so then it's maybe 128 gb). SD cards above 4gb are available. For mmc the highest capacity is 4gb
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