View previous topic :: View next topic |
Author |
Message |
curiousaboutcircuits85
Joined: 08 Apr 2010 Posts: 13
|
SD Card Memory Address Location using mmcsd.c PLEASE HELP! |
Posted: Sat Apr 17, 2010 2:32 pm |
|
|
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
|
|
Posted: Sat Apr 17, 2010 2:33 pm |
|
|
Also, I am using PIC18f4520 and a 2GB SanDisk SD Card. |
|
|
asmallri
Joined: 12 Aug 2004 Posts: 1635 Location: Perth, Australia
|
Re: SD Card Memory Address Location using mmcsd.c PLEASE HEL |
Posted: Sat Apr 17, 2010 10:04 pm |
|
|
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
|
|
Posted: Sun Apr 18, 2010 2:16 am |
|
|
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
|
regarding sd card |
Posted: Tue Nov 09, 2010 11:28 pm |
|
|
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
[email protected] |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Wed Nov 10, 2010 4:06 pm |
|
|
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 |
|
|
|