5 eeprom isr, 6 timer interrupt, 7 the xfer_busy, rtc and near_overflow interrupt – Maxim Integrated 71M6534 Energy Meter IC Family Software User Manual

Page 56: Eeprom isr, Timer interrupt, The xfer_busy, rtc and near_overflow interrupt

Advertising
background image

71M653X Software User’s Guide

execution paths can be made to occur. The early part of main() is convenient, and a simulated reset is an easy,
reliable way to get there.

The code does not display the normal reset indications when doing simulated resets, because when debugging
electrostatic discharge problems, displaying reset indications causes engineers to try to fix the reset pin, rather than
V1.

5.4.2.5

EEPROM Isr

The IC’s two-wire interface operates at the standard clock rate of about 30kHz. It can be operated reasonably
efficiently with a polling interface or an interrupting interface.

The interrupting interface (IO\eeprom.c) is installed in the demo code as an example. It uses less CPU time, and
interacts less with other system software. The interrupt steps through a state machine that writes the needed bytes to
read or write data to an Atmel EEPROM with 19-bit addressing.

A polling interface to the IC’s two-wire interface works well, and TSC uses one to support drivers for many other types
of EEPROMs. To install them, see the all-options code set (in io\iiceep.c, io\eepromp.c, io\eep24c08.c) or contact
factory support.

Bit-banging drivers are not recommended for the two-wire interface. In the two-wire interface, each 8 data bits sent are
followed by a received “ACK” bit. Some EEPROMs start the ack bit as soon as 50 nanoseconds after the clock line
falls. This can easily be before the bit-banging driver switches the data line to an input. The resulting brief, high-
frequency electrical short can cause system anomalies.

Typical EEPROMs delay 1.5 microseconds before asserting ACK, so bit-banging will usually work on the bench, but in
high-volume production, an occasional EEPROM will cause bus contention. It is possible to reduce the contention
current by placing a 1K resistor in the data line, but it’s even better to use non-contending driver software using the IC’s
two-wire electronics.

5.4.2.6

Timer Interrupt

timer0 of the MPU is the main system timer (IO\tmr0.c, .h). The demo code has it call a callback routine, so that the
timer code can be applied to any need. Also, the timer code can automatically run the timer as a periodic timer.

In the demo code, timer 0 is used to generate a 10ms timer tick, which is adjusted for the MPU’s clock speed. The
timer tick (variable tck_cnt) is started from and used to update the software timers (See Util\stm.c). The software
timers are updated by the stm_run() function in the main loop of the background task. Eight software timers can be
simultaneously running.

If it is desired to change the system timer to timer1, the include file called out in stm.c has to be changed to tmr1.h.

timer1 is unused, and may be used for other purposes. Tested code to operate timer 1 is available in the extended
code release.

Various macros are available to control the timers:

tmr_start(A, B, C

) has three parameters: A is the timer time, the number of ticks to reload on each

interrupt. B is true if the timer should restart itself when it expires. C is a pointer to a reentrant function.

tmr_stop()

stops the timer.

tmr_running()

returns TRUE if the timer is running.

These routines are very similar to the software timer commands, in stm.h.

5.4.2.7

The XFER_BUSY, RTC and NEAR_OVERFLOW Interrupt

All of these slow events share one external interrupt. The interrupt is decoded by an interrupt routine in Meter\io653x.c.

The XFER Busy interrupt (xfer_busyz_isr() in Meter\ce.c) is requested by the CE at the conclusion of every
accumulation interval. In the 6530 series, waits until the CE is operating, then it enables the pulse outputs. After that,
for every interrupt it just sets a flag to tell the background data that fresh metering data is available. The CE’s data is
read directly from CE RAM.

After reset the first second of data from the CE is discarded. It takes about one second for the PLL in the CE to settle
and (therefore) for the filtering to be reliable (variable ce_first_pass).

v1.1v1.1

TERIDIAN Proprietary

56 of 116

© Copyright 2005-2008 TERIDIAN Semiconductor Corporation

Advertising
This manual is related to the following products: