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

How to store SHT11 data in eeprom?

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



Joined: 17 Aug 2009
Posts: 1

View user's profile Send private message AIM Address ICQ Number

How to store SHT11 data in eeprom?
PostPosted: Mon Aug 17, 2009 11:44 am     Reply with quote

Hi,
I'm having project about humidity and temperature measurment and I'm using sht71. My code has used the file SHT.c and it works perfectly
but I have a little problem. I want to store humidity and temperature values in epprom 24c512. Each storage, address increase by one. I was wondering how not to lose address value when I reset (hard reset and soft reset).
Please help me, thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 17, 2009 1:28 pm     Reply with quote

This demo program may help:
http://www.ccsinfo.com/forum/viewtopic.php?t=22109&start=17
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Mon Aug 17, 2009 6:21 pm     Reply with quote

The program above is a great demo but copying it and using the concept
blindly- "as is" - can lead to design failure:

Namely the fact that the EEPROM storage address is in a random state after you program the PIC.

This is unacceptable for a delivered product .

One answer is to program the user space with a known default
as part of the PIC program process

Many program fixtures will let you do this - once you suss it out

Another answer that i prefer is to start with a seed of 0Xc5c5 ( int16 chk)
and create an additive checksum from, one or more bytes that i write to eeprom then the checksum follows the data you write

While there is a 1 in 0x10000 of this passing when it should not -
it has never let me down.

and all you have to do is make sure that adding the bytes you readback
to the initial seed value = equals the 2 byte checksum you read - following the data

and if you read back un_inited or corrupted_from_too_many_writes EEPROM - the checksum test will warn u




CHARS
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Mon Aug 17, 2009 8:32 pm     Reply with quote

It's not random. It's initialized to zero by this statement:
Code:
#ROM 0x2100 = {0x00}     // Initialize EEPROM address 0 = 0x00.

The above information is put into the HEX file by the compiler.
The initialization is done when the PIC is programmed.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Tue Aug 18, 2009 12:13 am     Reply with quote

Whenever I need to keep track of how much data I've written into an eeprom, I will save one address, of the eeprom, to store the last address written to. That way, when I reset or cycle power, I simply read that address and find out how much data was written and I can reassemble the data properly. It could be the last address that is available. Just make sure your program doesn't overwrite it with data.

Ronald
asmboy



Joined: 20 Nov 2007
Posts: 2128
Location: albany ny

View user's profile Send private message AIM Address

PostPosted: Tue Aug 18, 2009 8:13 am     Reply with quote

In my comments about init an checksum /CRC of EEPROM
I should have seen the INIT example - which is nice; and in a well integrated way - lets an initial value be set.

The comments about checking validity of eeprom data you write are worth serious consideration - if you are doing programming that MUST rely on the correctness of he EEPROM.
andys



Joined: 23 Oct 2006
Posts: 175

View user's profile Send private message

How to store SHT11 data in eeprom?
PostPosted: Sat Oct 06, 2012 8:33 pm     Reply with quote

If you use a flash memory is anything different or you can use the same code?
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