Energy Meter IC Family Software Instruction Manual

71M652X Software User’s Guide
Revision 1.7 TERIDIAN Proprietary 65 of 138
© Copyright 2005-2007 TERIDIAN Semiconductor Corporation
count==0?
EECTRL = 0x05 (stop command)
Clear all registers
End
NO
EEDATA= *(destination++)
EECTRL = 0x03 (multiple write with ACK command)
count- -
Start
interrupt rcvd?
(INT5)
Figure 5-20: Multi-Byte Write
Notes:
For larger EEPROMs, 1010xxR can be the first command (R=1 for read, R = 0 for write operation).
The START command should be sent to the EEPROM before any read or write operation
The algorithms cover single and multi-byte operations limited to a single page.
EEPROMs are organized in pages. In general, ATMEL EEPROMs have 1Kbyte per page (256 x 32 bits).
When reading, no special requirements with respect to page boundaries apply.
Special precautions apply when a page boundary is crossed for write operations: When the end of a page is
reached, the write.to the next page has to be preceded by a START command.
EEPROMs typically respond to START commands with 5ms delay.
Battery Test
The battery test is based on sampling the voltage applied to the VBAT pin during an alternative multiplexer cycle. The
function used for calculating the battery voltage from the count obtained from the ADC is int32_t mVBat (int32_t v).
In this function, the ADC sample count is shifted right 9 bits (to account for the left-shift operation automatically done by
the ADC). The measured value is not very accurate, since the chip-to-chip variations in offset and LSB resolution are
not calibrated (these may have 5% variations).
The routine battest_start() may be invoked from the command line interface. battest_start() sets the variable
bat_sample_cnt to 2. This signals to the XFER_BUSY interrupt (in ce.c) to take two measurement (to account for the
variations caused by the amplifier chopping). The RTC date is recorded in the structure last_day. That way, an
automated battery test is run only once per day (when the date changes right after midnight).
The routine battest_run (void) is called from the part of meter_run() that only operates when the CE is active. This is
because the battery test can only run when the CE is active. The routine battest_run (void) compares the current date
with last_day. If it detects a difference, indicating that the date has just changed), it calls battest_start ().