TERIDIAN Semiconductor Corporation makes no warranty for the use of its products, other than expressly contained in the
Company’s warranty detailed in the TERIDIAN Semiconductor Corporation standard Terms and Conditions. The company assumes
no responsibility for any errors which may appear in this document, reserves the right to change devices or specifications detailed
herein at any time without notice and does not make any commitment to update the information contained herein.
Figure 3-1: Port Speed and Handshake Setup ............................................................................................................... 19
Figure 4-1, Setup of Keil Compiler for bank-switched code ............................................................................................ 36
Figure 4-2, Selecting a Bank for a File Group in Keil C .................................................................................................. 37
Figure 4-3, Setting Keil’s Linker for Bank-switched Code ............................................................................................... 38
Figure 5-1: Sag and Dip Conditions ............................................................................................................................... 84
Figure 5-2: Sag Event .................................................................................................................................................... 84
Figure 5-3: Crystal Frequency over Temperature........................................................................................................... 85
Figure 5-5, State Diagram of Operating Modes ............................................................................................................ 101
Table 4-1: Code Bank Memory Addresses and Availability ............................................................................................ 35
Table 5-1: Internal Data Memory Map ............................................................................................................................ 43
Table 5-2: Internal Data Types ....................................................................................................................................... 46
Table 5-4: Current Sensing Options ............................................................................................................................... 47
Table 5-5: Compensation Features ................................................................................................................................ 48
Table 5-6: Power Registers and Pulse Output Features ................................................................................................ 49
Table 5-9: Calibration and Various Services .................................................................................................................. 51
Table 5-10: Interrupt Service Routines ........................................................................................................................... 53
Table 5-13: MPU Status Bits .......................................................................................................................................... 76
Table 5-14: Frequency over Temperature ...................................................................................................................... 85
Table 6-7: Notes on Data Addressing Modes ............................................................................................................... 105
Table 6-8: Notes on Program Addressing Modes ........................................................................................................ 105
Table 6-11: Data Transfer Operations .......................................................................................................................... 108
Table 6-12: Program Branches .................................................................................................................................... 109
Table 6-14: Instruction Set in Hexadecimal Order ........................................................................................................ 110
Table 6-15: Instruction Set in Hexadecimal Order ........................................................................................................ 111
Table 6-16: Instruction Set in Hexadecimal Order ........................................................................................................ 112
(“Licensed Software”) and provided by TERIDIAN Semiconductor Corporation (“TSC”), the recipient of the software
(“Licensee”) accepts, and agrees to be bound by the terms and conditions hereof.
Acknowledgment
TSC’s meter products: 71M6531, 71M6534, and 71M653xB. Licensee acknowledges that the Licensed Software was
not designed for use with, nor has it been checked for performance with, any other devices.
Title
: Title to the Licensed Software and related documentation remains with TSC and its licensors. Nothing contained
in this Agreement shall be construed as transferring any right, title, or interest in the Licensed Software to Licensee
except as expressly set forth herein. TSC expressly disclaims liability for any patent infringement claims based upon
use of the Licensed Software either solely or in conjunction with third party software or hardware.
Licensee shall not make nor to permit the making of copies of the Licensed Software (including its documentation)
except as authorized by this License Agreement or otherwise authorized in writing by TSC. Licensee further agrees not
to engage in, nor to permit the recompilation, disassembly, or other reverse engineering of the Licensed Software.
License Grant
ferable license to use the software solely in conjunction with the meter devices manufactured and sold by TSC.
Non-disclosure and confidentiality
Licensed Software and related documentation and information received by Licensee from TSC. All Confidential
Information shall be maintained in confidence by Licensee and shall not be disclosed to any third party and shall be
protected with the same degree of care as the Licensee normally uses in the protection of its own confidential
information, but in no case with any less degree than reasonable care. Licensee further agrees not to use any
Confidential Information received from TSC except as contemplated by the license granted herein.
Disclaimer of Warranty
Software, including any implied warranty of title, no infringement, merchantability, or fitness for a particular purpose,
regardless of whether TSC knows or has reason to know Licensee’s particular needs. TSC does not warrant that the
functions of the Licensed Software will be free from error or will meet Licensee’s requirements. TSC shall have no
responsibility or liability for errors or product malfunction resulting from Licensee’s use and/or modification of the
Licensed Software.
Limitation of Damages/Liability
LICENSEE FOR INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES IN CONNECTION WITH,
OR ARISING OUT OF, THIS LICENSE AGREEMENT OR USE OF THE LICENSED SOFTWARE.
Export: Licensee shall adhere to the U.S. Export Administration Laws and Regulations (“EAR”) and shall not export or
re-export any technical data or products received from TSC or the direct product of such technical data to any
proscribed country listed in the EAR unless properly authorized by the U.S. Government.
Termination
material breach within thirty (30) days from receipt of notice from TSC. Upon termination, Licensee shall return or, at
TSC’s option certify destruction of, all copies of the Licensed Software in its possession.
Law: This Agreement shall be construed in accordance with the laws of the State of California. The Courts located in
Orange County, CA shall have exclusive jurisdiction over any legal action between TSC and Licensee arising out of this
License Agreement.
Integration: This License Agreement constitutes the entire agreement of the parties as to the subject matter hereof.
No modification of the terms hereof shall be binding unless approved in writing by TSC.
: By using the Application Programming Interface and / or other software described in this document
: The Licensed Software has been developed for use specifically and exclusively in conjunction with
: TSC grants Licensee a limited, non-exclusive, non-sub licensable, non-assignable and non-trans-
: For the purpose of this Agreement, “Confidential Information” shall mean the
: TSC makes no representations or warranties, express or implied, regarding the Licensed
: IN NO EVENT WILL TSC NOR ITS VENDORS OR AGENTS BE LIABLE TO
: TSC shall have the right to terminate the license granted herein in the event Licensee fails to cure any
TERIDIAN Semiconductor Corporation’s (TSC) 71M653X single chip Energy Meter Controllers are a family of Systemson-Chip that supports all the functionalities required to build energy meters. Demo Boards are available for each chip
(71M6531, 71M6532, 71M6533, 71M6534) to allow development of embedded applications, in conjunction with an InCircuit Emulator.
Development of a 71M653X application can be started in either 80515 assembly language, or preferably in C using the
Demo Boards. TSC provides, along with the 71M653X Demo Boards, a development toolkit that includes a
demonstration program (“Demo Code”) written in ANSI C that controls all features present on the Demo Boards. This
Demo Code includes functions to manage the low level 80515 core such as memory, clock, power modes, interrupts;
and high level functions such as the LCD, Real Time Clock, Serial interfaces and I/Os. The use of Demo Code portions
will help reduce development time dramatically, since they allow the developer to focus on developing the application
without dealing with the low-level layer such as hardware control, timing, etc. This document describes the different
software layers and how to use them.
The Demo Code should allow customers to evaluate various resources of the 653X ICs but should not be
regarded as production code. The Demo Code and all its components, with the exception of the CE code, are
only example code and the use of it is “as is” and without implied guarantees. Customers may use the Demo
Code as a starting point at any given released revision level but should keep themselves informed about
subsequent revisions of the Demo Code. Demo Code revisions may not be directly compatible with previously
released revisions and/or embedded software used by customers. Custo mers need to ad apt the Demo Code or
other example code supplied by TERIDIAN Application Engineering to their own code base, and in this context
TERIDIAN Semiconductor can only provide indirect assistance and support.
This Software User’s Guide provides information on the following separate subjects:
• General software architecture and minimum requirements (Design Guide)
• Memory model, programming, test tools (Design Reference)
• Demo code structure, data flow, functions (Demo Code Description)
• Installing and using the EEP, compiler, ICE (Tool Installation Guide)
• Understanding and using the 80515 micro controller (80515 Reference)
1.1 USING THIS DOCUMENT
The reader should have a basic familiarity with microprocessors, particularly the 80515 architecture, firmware, software
development and power meter applications. Prior experience with, or knowledge of, the applicable ANSI and/or IEC
standards will also be helpful.
This document presents the features included in the 71M653X Demo Boards in terms of software and some hardware.
To get the most out of this document, the reader should also have available other 71M653X publications such as the
71M653X Demo Board User’s Manual, respective data-sheets, errata list and application notes for additional details
and recent developments.
Please refer to the following documents for further information:
• 71M653X Demo Board User’s Manual for the IC of interest
• 71M653X Data Sheet for the IC of interest.
• Signum Systems ADM-51 In-Circuit Emulator Manual (Software Version 3.11.4 or later)
• Keil Compiler Manual (Version 7.5 or later)
• μVision2 (Version 2.20a or later) Manual
TERIDIAN’s web site (http://www.teridian.com
helpful information.
Questions to TERIDIAN Applications Engineering can be directed via e-mail to the address:
• meter.support@teridian.com
) should be frequently checked for updates, application notes and other
1.3 COMPATIBILITY STATEMENT
Information presented in this manual applies to the following hardware and software revisions:
• 71M6531 and 71M6534 Demo Code Revision 4.4.15
• 71M6531 and Demo Board D6531N12A1 (68-pin QFN) Revision 1.0 or later
• 71M6534 Demo Board D6534T4A1 (120-pin LQFP) Revision 1.0 or later
• Signum Systems Wemu51 Software 4.4.11 (8/15/2007) or later
• Signum Systems ADM51 firmware version 4.4.11 (2007/07/15) or later
The revision 4.15 of the Demo Board Code is the basis for all discussed sources, commands, register
addresses and so forth. If applicable, known issues with revision 4.15 are disclosed within the code
description, and workarounds or improvements are shown.
This section provides designers with some basic guidance in developing power meter applications utilizing the TSC
71M653X devices. There are two types of applications that can be developed:
• Embedded application using the sources provided by TERIDIAN, or
• Embedded application using only customer generated functions.
2.1 HARDWARE REQUIREMENTS
The following are the minimum hardware requirements for developing custom programs:
•TERIDIAN 71M6531 Demo Board. This board interfaces with a PC via the RS232 serial interface (COM
port).
• AC Adaptor (AC/DC output) or variable power supply.
• PC Pentium with 512MB RAM and 10GB hard drive, 1 COM port and 1 USB port, running either Windows
2000, or Windows ME or Windows XP.
•Signum Systems ADM-51 In-Circuit Emulator (for loading and debugging the embedded application) and
its associated cables. Signum references this device as ADM-51.
2.2 SOFTWARE REQUIREMENTS
The following are the minimum software requirements for embedded application programming:
• Keil Compiler version 8.03a or later.
• μVision2 version 3.33 (Note: this version comes with Keil Compiler version 8.03a).
• Signum Systems software Wemu51 (comes with Signum Systems ADM-51 ICE hardware).
The following software tools/programs are included in the 71M653X development kit and should be present on the
development PC:
•Demo Code with Command Line Interface (CLI) - Used to interface directly to metering functions and to
the chip hardware.
In order to generate and test software, the Keil compiler and the Signum in-circuit emulator (ICE) must be installed per
the instructions in section 4. The include files and header files must also be present on the development PC. Typically,
a design session consists of the following steps:
• Editing C source code using µVision2
• Compiling the source code using the Keil compiler
• Modifying the source code and recompiling until all compiler error messages are resolved
• Using the assembler and linker to generate executable code
• Downloading the executable code to the ICE
• Executing the code and watching its effects on the target
2.3 SOFTWARE ARCHITECTURE
The 71M653X software architecture is partitioned into three separate layers:
1. The lowest level is the device or hardware layer, i.e. the layer that directly communicates with the discrete
functional blocks of the chip and the peripheral components (“hardware”), such as serial interfaces, AFE, LCD
etc.
2. The second layer consists of buffers needed for some functions.
3. The third layer is the application layer. This layer is partially implemented by the Demo Code for evaluation
purposes, but extensions and enhancements can be added by the application software developer to design
suitable electronic power meter applications.
Figure 2-1: shows the partitions of each software component. As illustrated, there are many different designs an
application can develop depending on its usage. Section 5 describes in more detail the functions within each
component.
The Demo Code is modular. Each device in the chip and on the Demo Board has a corresponding set of driver
software in the Hardware Layer. These driver software modules are very basic, enabling customers to easily locate and
reuse the logic. For the serial devices and for the CE, the buffer handling has been separated from the driver modules.
Where there are several similar devices (e.g. ser0, ser1, or tmr0, tmr1), the Demo Code simulates a virtual object base
class using C preprocessor macros. For example, to initialize the first serial interface, ser0, the source file can include
ser0.h, and then call ser_initialize(). To transmit a byte on ser0, the file can include ser0.h, and then call
ser_xmit(). The convenience is that high-level code can be ported to another device by just (for example) including
ser1.h, rather than ser0.h. Just by making variables static, entire high-level protocols can be written and maintained by
copying the code debugged on one device, and having it include the other device’s .h file.
The demo firmware uses this technique for the command line interface (ser0cli.c, ser1cli.c), the FLAG AMR interface
(flag0.c, flag1.c) and for the software timer module (stm.c). The base-class emulation uses macros because on the
80515 MPU macros execute faster and are also more compact than the standard C++ (object-oriented) design with an
implicit structure containing function pointers.
The Demo Code is also designed with an “options.h” file, which enables and disables entire features in the firmware.
The macro approach combined with the “options.h” file permitted the firmware team to adapt the same Demo Code to
both the 6531 and 6534 versions.
2.4 UTILITIES
Three utilities are offered that make it possible to perform certain operations on the object (HEX) files without having to
use a compiler:
•D_MERGE.EXE allows combining the object file with a text script in order to change certain default settings of
the program. For example, modified calibration coefficients resulting from an actual calibration can be inserted
into the object file.
• CE_MERGE.EXE allows combining the object file with an updated image of the CE code.
• BANK_MERGE.EXE combines the hex files the Keil tools provide for each code bank.
All utilities are executed from a DOS window (DOS command prompt). To invoke the DOS window, the “command
prompt” option is selected after selecting Start – All Programs – Accessories.
The GUI subdirectory contains an unsupported MS Windows .NET implementation of a FLAG hand-held unit.
2.4.1 D_MERGE
Many changes to the firmware’s defaults can be made permanent by merging them into the object file. The first step for
this is to create a macro file (macro.txt) containing the commands adjusting the I/O RAM or other defaults, such as the
following commands affecting calibration:
]8=+16381
]9=+16397
]E=+237
The d_merge program updates the 653x_demo.hex file with the values contained in the macro file. The d_merge
program must be in the same directory as the source files, or a path to the executable must be declared. Executing the
d_merge program with no arguments will display the syntax description. To merge the file macro.txt and the object file
old_653x_demo.hex into the new object file new_653x_demo.hex, use the command:
The ce_merge program updates the 653x_demo.hex file with the CE program image contained in the CE.CE file
and the data image CE.DAT. Both CE.CE and CE.DAT must be i
source format but in the compiled format (intel hex). These files will be made available from Teridian in the
cases when updates to the CE images are necessary.
To merge the object file old_653x_demo.hex with CE.CE and CE.DAT into the new object file new_653x_demo.hex,
use the command:
n Intel HEX format, i.e. both files are not in the
If using Keil’s professional package, bank_merge.exe is not needed to produce Intel-386 files from banked code.
Simply go to the pull-down hex file selection in the output section of the project configuration of uVision, and select
“i386”. Keil’s premium OHX51 hex file converter will automatically produce a single intel-386 file containing all the code
banks.
If producing banked code with Keil’s standard package, the BL51 linker is tightly coupled to the OC51 and OH51 code
converters. These produce one 64K Intel hex file for each code bank. The Signum emulator and TSC’s TFP (in-circuit
programmer) require that banked code be in a different format, a single Intel-386 hex file.
Bank_merge.exe is a program that converts Keils’ multiple hex files into a single Intel-386 hex file.
Usage: bank_merge <Number of Banks> <ROM Size> <Input Name> <Output>\n");
<Number of Bank> - 3 for 6531, and 7 for 6534");
<ROM Size> - The memory size of ROM in kbyte (128,256,...)"
<Input> - Compiled files' name without extension"
<Output> - Output file name. Must have '.hex' extension\n");
For example:
bank_merge 3 128 banktest31 new_code.hex
This merges the three compiled hex files, banktest31.H01, banktest31.H02, banktest31.H03 and produces
new_code.hex in a 128kbyte intel-386 hex file.
As depicted in Figure 1 of section 2, the 71M653X provides a great deal of design flexibility for the application developer. Programming details are described below.
3.1 PROGRAM MEMORY
The embedded 80515 MPU within the 71M653X has separate program (128K or 256K bytes) and data memory (4K
bytes). The code for the Compute Engine program resides in the MPU program memory (flash).
The Flash program memory is addressed as a 64KB block. The upper 32K is a window on a code banked. It can be
switched to other code banks by writing a banke numbe rto the banked register FL_BANK. The flash memory is further
segmented in 512-byte pages which can be individually erased. Selection of these individual blocks is accomplished
using the function calls related to flash memory, which are described in more detail below.
3.2 DATA MEMORY
The 71M653X has 4K bytes of Data Memory used by the embedded 80C515 MPU, and shared with the proprietary
computer-engine (CE). In most configurations, the CE uses 1K of this RAM, leaving 3K for use by the MPU. See Table
3-1: for a summary.
Address
(hex)
0000-7FFF Flash Memory Non-volatile
8000-FFFF Flash Memory Non-volatile
0000-03FF Static RAM Volatile
0400-1000 Static RAM Volatile MPU data 0 3KB
2000-20FF Static RAM
Memory
Technology
Memory Type Typical Usage
Common code area for the
program and non-volatile
data.
Bank window code area for
the program and nonvolatile data. The 6531, 32,
and 33 have 3 banks
yielding 128K total. The
6534 has 7 banks, yielding
256K total
CE data, actual last byte
may be somewhat less than
1K, depending on the CE
code.
There are two ways to download a hex file to the 71M653X Flash Memory:
• Using a Signum Systems ADM-51 ICE.
• Using the TERIDIAN Semiconductor Flash Download FDBM-TFP-2 Stand-Alone Module
Note: For both programming and debugging code it is important that the hardware watchdog timer is
disabled. See the Demo Board User’s Manual for details.
Before downloading code to a 71M653x:
• Stop the MPU
• Disable the CE by writing a 0 to XDATA at address 0x2000.
• Erase the flash memory.
3.4 DEBUGGING OF THE 71M653X CHIPS
When debugging with the ADM51 in-circuit emulator, the CE continues to run, and this disables flash memory access
because the code of the CE is located in flash memory.
When setting breakpoints, only tw o breakpoints can be used, because the first two breakpoints are
“hardware” breakpoints, while the rest attempt to write to flash memory.
3.5 TEST TOOLS
A command line interface operated via the serial interface of the 71M653X MPU provides a test tool that can be used
to exercise the functions provided by the low-level libraries. The command-line interface requires the following
environment:
1) Demo Code (653X_demo.hex) must be resident in flash memory
2) The Demo Board is connected via a Debug Board to a PC running Hyperterminal or another type of terminal
program.
3) The communication parameters are set at 300 bps, 7N2, XON/XOFF flow control, as described in section
This object file is the 71M653X embedded application developed by TERIDIAN to exercise all low-level function calls
using a serial interface. Demo Boards ship pre-installed with this program. To run this program:
•Connect a serial cable between the serial port of the Debug Board RS232 and a COM port of a Windows
PC.
•Open a Windows’ Hyperterminal session at 2400 or 300 bps (depending on jumper settings – see the
DBUM), 8N1, one stop bit with XON/XOFF flow control enabled. The setup dialog box is shown in Figure 3-1: Port Speed and Handshake Setup.
•Power on the Demo Board and hit <CR> a few times on the PC keyboard until ‘>’ is displayed on the
Hyperterminal screen.
• Type a command from the CLI Reference ( 3.5.2 )
• All references to ‘c’ (lower case c) indicate any ASCII character, all other lowercase letters are one-byte
numbers
•Numbers can be entered in decimal by preceding them with a plus-sign (e.g. hex 20 = +32)
The 71M653x Demo Board User’s Manual contains instructions on how to connect the serial cable.
Note: HyperTerminal can be found by selecting Programs ÆAccessories Æ Communications from the Windows
start
menu. The connection parameters are configured by selecting File Æ Properties and then by pressing the
Configure button. Port speed and flow control are configured under the General tab, bit settings are configured
by pressing the Configure button (Figure 3-1: Port Speed and Handshake Setup) as shown below.
The Demo Board User’s Manual (DBUM) for the 71M653x contains a complete list of the available commands.
3.5.3 Command (Macro) Files
Commands or series of commands may be stored in text (ASCII) files and sent to the 71M653X using the “Transfer –
Send Text File” command of Hyperterminal or any other terminal program.
The Wemu51 program communicates with the emulator ADM51 via the USB interface of the PC. The USB driver for
the ADM51 has to be installed prior to using the emulator. After plugging in the USB cable into the PC and the ADM51
ICE the status light of the ADM51 emulator should come on.
A dialog box will appear, asking you to install the ADM51 driver.
Click Next. Another dialog box will appear, asking how to search for the driver. Use the recommended method.
Click Next.
Another screen (not shown) will appear asking to locate the driver. Select Specific Path and browse to:
Note: USB 1.1 is sufficient for operation of the ADM51. If higher performance is desired and no USB 2.0 port is
available on the host PC, a USB 2.0 card can be installed as an option.
4.4 INSTALLING UPDATES TO THE EMULATOR PROGRAM AND HARDWARE
If the Wemu51 program is revision 3.11.4 or later, no special precautions have to be taken. Otherwise, the program
should be updated using the Signum Systems web site (www.signum.com
When running the Wemu51 program revision 3.11.4 or later, the firmware in the ADM51 will be checked automatically.
ADM51 emulators with outdated firmware will not function properly. The Wemu51 will offer an automatic update for the
ADM51, if necessary. For a successful upgrade it is vital to follow the instructions on screen precisely.
When prompted for the project name to be used, type a convenient project name. Click Next.
When prompted for the project directory to be used, select an existing folder on the PC. Do NOT select any folder in the Wemu51 installation directory! Click Next.
When prompted for the emulator to be used, select ADM51 Emulator. Click Next.
The following directory structure is established when the files from the archive 653X_Demo.zip are unpacked while
maintaining the structure of subdirectories:
<drive letter>:\…\meter project\
<drive letter>:\…\meter project\CE
<drive letter>:\…\meter project\CLI
<drive letter>:\…\meter project\docs
<drive letter>:\…\meter project\flag
<drive letter>:\…\meter project\IO
<drive letter>:\…\meter project\Main
<drive letter>:\…\meter project\Main_653x_CLI
<drive letter>:\…\meter project\Meter
<drive letter>:\…\meter project\Util
The project control file 653X_demo.uv2 will be in the directory <drive letter>:\…\meter project. The Keil compiler can be
configured easily by loading the file 653X_demo.uv2, using the Project Menu and selecting the Open Project
command.
The window shown below should appear when the project control file is opened.
The Project Workspace screen on the left side of the window shows the main components of the source (CE, CLI, IO,
Main, Meter, Utils) in folders. Folders can be opened by clicking on the plus sign next to them. Opening the folders will
display the source files associated with them.
It should be noted that not all header files are physically present in the project directory. The files absacc.h, string.h,
ctype.h, and setjmp.h are provided by the compiler manufacturer, and they are located in the Keil\C51\INC directory.
4.7.2 Adjusting the Keil Compiler Settings
Once, the Keil compiler is installed, the most convenient method to start the project is to double-click on the file
653x.UV2 (or 653x.UV3). This will start the Keil compiler with the proper settings stored in the 653x.UV2 file.
Directory structures and drive names vary from PC to PC. The settings for the compiler can be adjusted using the
following method:
1. Select “target1” in the leftmost window.
2. Select “project” from the top menu and then select “options for target 1”.
3. Select the “C51” tab.
4. Click the button right next to the “Include Paths” window. Three paths will be listed, pointing to meter
projects, meter projects\demo, and meter projects\demo\header files.
5. If necessary, delete these path entries (X button) and replace them with the corresponding path
entries for your PC ( button).
The dialog box should look like shown below. After making the necessary changes, the project file (653X_demo.UV2)
should be stored.
4.7.3 Manually Controlling the Keil Compiler Settings
If the method described in section “Adjusting the Keil Compiler Settings” is not used, the Keil compiler settings can also
be controlled manually.
The target options should be selected in order to adapt the compiler controls properly to the target. The uVision
compiler environment is started by selecting Programs Æ Keil Æ uVision2. uVision should start up and present the
following window:
Under Project Æ Options for Target1, select the Device tab and check the selected device. Newer versions of the Keil
Compiler offer selection of TERIDIAN (labeled “TDK”) 71M653x devices: