View previous topic :: View next topic |
Author |
Message |
lucky
Joined: 12 Sep 2003 Posts: 46 Location: South Coast - England
|
CF Write code |
Posted: Thu Mar 17, 2005 10:42 am |
|
|
Young,
Code: |
for(i=compactFlashPosition;i<offset;i++){
compactFlashPosition++;
CF_ReadData(0);
}
|
is used to seek in to the sector by the required amount of bytes passed in offset.
To write 1536 byes to sector 15 put the first 512 bytes into buffer[0] - buffer[511] and call write_sector(15); then load the second 512 bytes of data into buffer[0] - buffer[511] and call compactFlashWriteBuffer(512,512); then load the third 512 bytes of data into buffer[0] - buffer[511] and call compactFlashWriteBuffer(1024,512);
... I think. Like I said, it has been a long time.
The best way to learn it to just try the code (over and over again) until YOU get it to work. It took me many hours learning to get this working. _________________ Lucky
www.mpic3.com - MPIC3 player project, Forum, Downloads, Online Shop |
|
|
young
Joined: 24 Jun 2004 Posts: 285
|
|
Posted: Thu Mar 17, 2005 11:54 am |
|
|
Thank you Lucky:
Does you imply that my code for write_sector(), and compactFlashWriteBuffer() function are correct, I would like to get your oppinion about my code, is that correct, do I need any other correction? |
|
|
Guest
|
|
Posted: Thu Mar 17, 2005 2:48 pm |
|
|
I am debuging the program, however, the definition of buffer[512] is out of range, I checked the RAM of 16f877a, the maximum expand of each bank upto 128 byte. according to this the program has to be changed. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Mar 17, 2005 2:54 pm |
|
|
Use a PIC18! or you will have to add external RAM or FRAM |
|
|
Guest
|
|
Posted: Thu Mar 17, 2005 2:57 pm |
|
|
Thank you mark:
Thank you for you suggestion, I will try on the 18f chips. by the way, you said about the add external ram, or fram, would you please add some clue how and what kinds of ram or fram on the market? |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Thu Mar 17, 2005 3:13 pm |
|
|
You will need to store at least 512 bytes to do the writes. If the micro does not have enough RAM, you will have to use external. FRAM memory is the same as a serial eeprom except the writes are instance and virtually unlimited write cycles. Another option would be to use an external SRAM chip. Search for the MP3 projects on the net and you will find some examples of SRAM usage. |
|
|
lucky - not logged in Guest
|
CF Writes |
Posted: Fri Mar 18, 2005 10:34 am |
|
|
I use the 18F452, its a great chip with loads of space. Mark is correct, you will need 512 bytes to write. |
|
|
|