View previous topic :: View next topic |
Author |
Message |
dinhthi
Joined: 17 Aug 2009 Posts: 1
|
How to store SHT11 data in eeprom? |
Posted: Mon Aug 17, 2009 11:44 am |
|
|
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
|
|
|
asmboy
Joined: 20 Nov 2007 Posts: 2128 Location: albany ny
|
|
Posted: Mon Aug 17, 2009 6:21 pm |
|
|
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
|
|
Posted: Mon Aug 17, 2009 8:32 pm |
|
|
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
|
|
Posted: Tue Aug 18, 2009 12:13 am |
|
|
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
|
|
Posted: Tue Aug 18, 2009 8:13 am |
|
|
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
|
How to store SHT11 data in eeprom? |
Posted: Sat Oct 06, 2012 8:33 pm |
|
|
If you use a flash memory is anything different or you can use the same code? |
|
|
|