|
|
View previous topic :: View next topic |
Author |
Message |
altra22
Joined: 14 May 2007 Posts: 11
|
internal eeprom management |
Posted: Sat Jan 01, 2011 1:39 pm |
|
|
Hi All
Can I implement ex_malloc.c example to internal eeprom ? My PIC is 16F876A which has 256 byte of EEPROM. I want to store users and delete users (Rarely).
So I cannot do it while run-time via Serial interface. In other memories
when the PIC Power fail/down all variables are gone so I am going to store about 100 bytes ->10 users 9 char +null character in EEPROM.
But should I store also the pointers and structures to EEPROM
Code: |
write_eeprom(i,num);
write_eeprom(i,key);
write_eeprom(i,count);
write_eeprom(i,* beginCell);
write_eeprom(i,* endCell);
write_eeprom(i,* pCell);
write_eeprom(i,* pCell2);
|
No simulators here but real hardware. My version 4.105.
Thanks in Advance |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19496
|
|
Posted: Sat Jan 01, 2011 2:37 pm |
|
|
Realistically, just do it yourself.
Malloc is too complex for what you describe.
Just treat the entries as 'records' Add a flag to say that the record is active (why would you want a null, this is part of string management....). Store this as a separate array at the start of the EEPROM. Then on boot up, just read these flags. If it is non zero (active), read the nine byte record and transfer to your RAM array (and add the termination). If it is zero, advance to the next record. When you need to add a record, just look for the first zero flag. Effectively you are implementing a very crude 'FAT' system.
Best Wishes |
|
|
|
|
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
|