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 CCS Technical Support

AT24C64-data logging in circular buffer type

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



Joined: 29 Nov 2007
Posts: 15

View user's profile Send private message

AT24C64-data logging in circular buffer type
PostPosted: Thu Oct 14, 2010 6:05 am     Reply with quote

hi all,
I am working on a energy meter project with MAXQ3180, PIC18F6722 and 4.020 CCS compiler.
I want to store the data from energy meter to 24C64 EEPROM (5 no.s)which is connected through i2c. I want data to be stored in circular fashion so that at any time I can access last 100 entry's.
I can write and read eeprom with easy and can log 72 bytes of data on predefined time. But cannot make it in circular buffer as I don't have the last address as there are number of ICs.
After ICs become full, my data get overwritten on old values.
How to deal with it? Is there any simple method to do that.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Thu Oct 14, 2010 9:09 am     Reply with quote

Store the data in a format, that allows to identify the last write position without an explicite write pointer. E.g. the last block before an erased block is assumed as last write position. The only prerequisite is to erase the next block before writing a new one. On application startup, you can search the stored data, until you find the first erased block. It's the next write position.
languer



Joined: 09 Jan 2004
Posts: 144
Location: USA

View user's profile Send private message

PostPosted: Thu Oct 14, 2010 10:59 am     Reply with quote

You could use the first two EEP locations to store the next free address. In your program you have to keep track of which address you're writing to (even if you're using the auto-increment feature - read PAGE WRITE). You have to make sure that when you're back at the first page, the first two EEP locations are "skipped".

After I wrote this, I did a quick search on the forum and there was a similar post: http://www.ccsinfo.com/forum/viewtopic.php?t=41312&highlight=eeprom+address+pointer
pad



Joined: 29 Nov 2007
Posts: 15

View user's profile Send private message

PostPosted: Thu Oct 14, 2010 10:38 pm     Reply with quote

Thanks FvM & languer for your quick & valuable response.
I have 5 EEPROMS(A0,A2,A4,A6,A8). Of which I start data logging from 2nd A2 to 5th A8. I check the address before write the data. If eeprom is full then jump to next IC. Here I have only last address so if I want to retrieve the data I need to start from currently logged one. Of which starting address I can found. But how to get other starting addresses as they may be on other ICs.
Hope you people understand what I want to say. Suppose my latest data is on A4 and its previous data is on A2 then A8, A6 and A4. So how I get their starting addresses. Can I subtract 72 byte locations from each last address to get starting address of each block, as I know I am writing 72 bytes each time, or need to save each blocks start and end address in eeprom & access them to read again.
FvM



Joined: 27 Aug 2008
Posts: 2337
Location: Germany

View user's profile Send private message

PostPosted: Fri Oct 15, 2010 12:44 am     Reply with quote

Both suggested methods can be extended to multiple memory devices, if you treat them logically as one large memory space. Some more detail programming is involved, of course.

The main difference betwen using a dedicated pointer location or an implicite marking of the next write location, as I suggested, is in the achieved wear leveling. If wear leveling is a concern at all, depends on your application requirements, particularly the average write frequency. In any case, you should review the respective memory endurance specifications and check, if they are sufficient for your intended usage.
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