Maxim Integrated 71M6521BE Energy Meter IC Family Software User Manual
Page 47

71M652X Software User’s Guide
Revision 1.7
TERIDIAN Proprietary
47 of 138
© Copyright 2005-2007 TERIDIAN Semiconductor Corporation
Before the MPU gets to execute the main() program, it will execute the startup instructions contained in the
STARTUP.A51 assembly program (Figure 5-1). Upon completion, STARTUP.A51 causes a jump to the label
C_START, which is contained in the second startup assembly program named init.A51 (Keil/C51/LIB directory, see
Figure 5-2). Init.A51 finally causes the jump to main(). The startup files are described in section 5.10 .
Reset Watchdog
Process WD Overflow flag
main()
Set WAKE timer to 7s
BROWNOUT mode?
Clear PB and WAKE flags
Enter LCD mode
PB pressed?
Clear PB and WAKE flags
main_init()
main_run()
Enter SLEEP mode
no
yes
yes
no
Figure 5-3: main() Program
The stack is located at 0x80, growing to higher values, while the reentrant stack is located at 0xFF, growing down-
wards.
Once operating, the main() program (Figure 5-4 )expects regular interrupts from the CE. If no interrupts occur, the
main() program will cease to trigger the watchdog timer, resulting in a reset condition, if the watchdog timer is enabled.
The main() program calls the main_init() (Figure 5-4) and the main_run() (Figure 5-5) routines. main_init() is used for
hardware and software initialization, main_run() is the routine that is executed in an endless loop and that takes care of
background and foreground processing.