71M6521BE-DB Maxim Integrated Products, 71M6521BE-DB Datasheet

no-image

71M6521BE-DB

Manufacturer Part Number
71M6521BE-DB
Description
Power Management Modules & Development Tools 71M6521BE DEMO BOARD M6521BE DEMO BOARD
Manufacturer
Maxim Integrated Products
Datasheet

Specifications of 71M6521BE-DB

Lead Free Status / RoHS Status
Lead free / RoHS Compliant
71M6521D/71M6521F
71M6521B
Energy Meter IC Family
SOFTWARE USER’S GUIDE
8/6/2008
Revision 1.7
TERIDIAN Semiconductor Corporation
6440 Oak Canyon Rd., Suite 100
Irvine, CA 92618-5201
Ph: (714) 508-8800 ▪ Fax: (714) 508-8878
Meter.support@teridian.com
http://www.teridian.com/

Related parts for 71M6521BE-DB

71M6521BE-DB Summary of contents

Page 1

Energy Meter IC Family SOFTWARE USER’S GUIDE 8/6/2008 Revision 1.7 TERIDIAN Semiconductor Corporation 6440 Oak Canyon Rd., Suite 100 Irvine, CA 92618-5201 Ph: (714) 508-8800 ▪ Fax: (714) 508-8878 Meter.support@teridian.com http://www.teridian.com/ ...

Page 2

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 ...

Page 3

Software User’s Guide Revision 1.7 © Copyright 2005-2007 TERIDIAN Semiconductor Corporation Energy Meter IC FAMILY SOFTWARE USER’S GUIDE TERIDIAN Proprietary 71M652X 3 of 138 ...

Page 4

Table of Contents 1  . ............  I NTRODUCTION 1.1  Using this Document ............................................................................................................................. 1.2  Related Documentation ......................................................................................................................... 1.3  Compatibility Statement ........................................................................................................................ 2  . ............  D ESIGN GUIDE 2.1  Hardware Requirements ........................................................................................................................ 2.2  Software Requirements ......................................................................................................................... 2.3  Software Architecture ............................................................................................................................ 2.4  ...

Page 5

Software User’s Guide 5.3  Program Flow ......................................................................................................................................... 5.3.1  Startup and Initialization 5.4  Basic Code Architecture ........................................................................................................................ 5.4.1  Initialization 5.4.2  Foreground Timer Interrupt ...................................................................................................................... 51  CE_BUSY Interrupt ............................................................................................................... 53  XFER_BUSY and RTC Interrupt ........................................................................................... 53  5.4.2.1  SERIAL Interrupt .................................................................................................. 55  ...

Page 6

... Memory Use 5.17.2  CE Code Location 5.17.3  Battery Modes 5.17.4  Three-Wire EEPROM Hardware 5.17.5  Temperature Compensation 5.18  TEST Modules ........................................................................................................................................ 5.18.1  6513 CE Example 5.18.2  Serial Port Tests 5.18.3  Timer Tests 5.18.4  EEPROM Tests 5.18.5  ...

Page 7

Software User’s Guide Program Counter................................................................................................................. 120  Ports 120  Timers 0 and 1 .................................................................................................................... 120  Timer/Counter Mode Control Register (TMOD) .................................................................. 121  Timer/Counter Control Register (TCON) ............................................................................. 121  6.3.2.1  Allowed Combinations of Operation Modes ........................................................ 122  6.3.3  Serial Interface 0 ...

Page 8

List of Figures Figure 2-1: Software Structure ....................................................................................................................................... 16 Figure 3-1: Port Speed and Handshake Setup ............................................................................................................... 21 Figure 5-1: STARTUP.A51 ............................................................................................................................................. 46 Figure 5-2: INIT.A51 ....................................................................................................................................................... 46 Figure 5-3: main() Program ............................................................................................................................................ 47 Figure 5-4: main_init() Function ..................................................................................................................................... 48 ...

Page 9

Software User’s Guide Table 5-4: Current Sensing Options ............................................................................................................................... 42 Table 5-5: Compensation Features ................................................................................................................................ 42 Table 5-6: Power Registers and Pulse Output Features ................................................................................................ 43 Table 5-7: Creep Functions ............................................................................................................................................ 44 Table 5-8: Operating Modes ........................................................................................................................................... 44 Table ...

Page 10

Table 6-30: Serial 1 Modes .......................................................................................................................................... 124 Table 6-31: The S1CON Register ................................................................................................................................ 124 Table 6-32: The S1CON Bit Functions ......................................................................................................................... 125 Table 6-33: The IEN0 Register ..................................................................................................................................... 127 Table 6-34: The IEN0 Bit Functions ............................................................................................................................. 127 Table 6-35: The ...

Page 11

Software User’s Guide LIMITED USE LICENSE AGREEMENT Acceptance: By using the Application Programming Interface and / or other software described in this document (“Licensed Software”) and provided by TERIDIAN Semiconductor Corporation (“TSC”), the recipient of the software (“Licensee”) accepts, ...

Page 12

Revision 1.7 © Copyright 2005-2007 TERIDIAN Semiconductor Corporation 71M652X Software User’s Guide TERIDIAN Proprietary 12 of 138 ...

Page 13

... TERIDIAN Semiconductor Corporation’s (TSC) 71M652X single chip Energy Meter Controllers are a family of Systems- on-Chip that supports all functionalities required to build a low-cost power meter. Demo Boards are available for each chip (71M6521DE/FE, 71M6521BE) to allow development of embedded application, in conjunction with an In-Circuit Emulator. Development of a 71M652X application can be started in either 80515 assembly language, or more favorably in C using the Demo Boards. TSC provides, along with the 71M652X Demo Boards, a development toolkit that includes a demonstration program (“ ...

Page 14

... RELATED DOCUMENTATION Please refer to the following documents for further information: • 71M6521 Demo Board User’s Manual • 71M6521DE/FE or 71M6521BE Data Sheet • Signum Systems ADM-51 In-Circuit Emulator Manual • Keil Compiler Manual (Version 7.5 or later) • μVision2 (Version 2.20a or later) Manual TERIDIAN’ ...

Page 15

Software User’s Guide 2 DESIGN GUIDE This section provides designers with some basic guidance in developing power meter applications utilizing the TSC 71M652X devices. There are two types of applications that can be developed: • Embedded application using the ...

Page 16

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, ...

Page 17

... The Demo Code is highly 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 abstracted and separated from the driver modules ...

Page 18

Revision 1.7 © Copyright 2005-2007 TERIDIAN Semiconductor Corporation 71M652X Software User’s Guide TERIDIAN Proprietary 18 of 138 ...

Page 19

Software User’s Guide 3 DESIGN REFERENCE As depicted in Figure 1 of section 2, the 71M652X provides a great deal of design flexibility for the application de- veloper. Programming details are described below. 3.1 PROGRAM MEMORY The embedded 80515 ...

Page 20

PROGRAMMING OF THE 71M652X CHIPS There are two ways to download a hex file to the 71M652X Flash Memory: • Using a Signum Systems ADM-51 ICE. • Using the TERIDIAN Semiconductor Flash Programmer Module (FDBM) or the TERIDIAN Semiconductor ...

Page 21

Software User’s Guide 3.5.1 Running the 652X_Demo.hex Program This object file is the 71M652X 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 ...

Page 22

... Note: Only the 71M6521FE chip has enough memory to support a serial command line interface in addition to its metering functions. Communication with the 71M6521BE and 71M6521DE chips is implemented with a simpler interface, based on Intel hex records. This interface is also described in the Demo Board User’s Manual. ...

Page 23

Software User’s Guide 4 TOOL INSTALLATION GUIDE This section provides detailed installation instructions for the Signum ADM-51 in-circuit emulator and for the Keil compiler. 4.1 INSTALLING THE PROGRAMS FOR THE ADM51 EMULATOR The AMD51 ICE interfaces with the PC ...

Page 24

INSTALLING THE ADM51 USB DRIVER 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 ...

Page 25

Software User’s Guide Click Finish. Click Finish again. 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 ...

Page 26

CREATING A PROJECT Double click on the WEMU51 icon to start the Chameleon debugger. Click Project/Create New Project. The following screen will appear: Follow the instructions of the Create Project Wizard by selecting Next. Revision 1.7 © Copyright 2005-2007 ...

Page 27

Software User’s Guide 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 ...

Page 28

When prompted for the communication device to be used, select USB ADM51. Click Next. When prompted for the processor to be used, select either 71M6521. Click Next. Click Finish. Revision 1.7 © Copyright 2005-2007 TERIDIAN Semiconductor Corporation 71M652X Software User’s ...

Page 29

Software User’s Guide 4.6 INSTALLING THE KEIL COMPILER After inserting the Keil CD-ROM into the CD drive of the PC, the on-screen instructions should be followed to install the Keil compiler. Note: For PCs that can only use one ...

Page 30

CREATING A PROJECT FOR THE KEIL COMPILER 4.7.1 Directory Structure The following directory structure is established when the files from the archive 652X_Demo.zip are unpacked while maintaining the structure of subdirectories: <drive letter>:\…\meter project\ <drive letter>:\…\meter project\CE <drive letter>:\…\meter ...

Page 31

Software User’s Guide 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 ...

Page 32

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 ...

Page 33

Software User’s Guide For older versions of the Keil compiler, select the TERIDIAN folder (labeled “TDK”), open it by clicking on the + sign and select 73M2910L as the target device. Confirm by clicking OK. Under Project Options for ...

Page 34

Under the Output tab, select a name for the executable (object) file with .abs extension’ in the field labeled “Name of the executable” and check the fields by “Debug Information”, “Browse Information” and “Create HEX File”. This will guarantee that ...

Page 35

Software User’s Guide 4.8 PROJECT MANAGEMENT TOOLS With large software projects involving a multitude of source, object, list and other files in various revisions very helpful to use a version control tool. To manage file versions under ...

Page 36

Some editors to be considered are: • VIM, see http://www.vim.org/ a free VI editor. VIM is available in full-featured versions for Windows part of the POSIX standard, so using portable skill. VIM wins awards for ...

Page 37

Software User’s Guide 5 DEMO CODE DESCRIPTION 5.1 80515 DATA TYPES AND COMPILER-SPECIFIC INFORMATION 5.1.1 Data Types The 80515 MPU core is an 8-bit micro controller (MPU); thus operations that use 8-bit data types such as “char” or “unsigned ...

Page 38

General data type definitions: uint8_t; typedef unsigned char uint16_t; typedef unsigned short uint32_t; typedef unsigned long int8_t; typedef signed char int16_t; typedef signed short int32_t typedef signed long Type definitions for internal data, lower 128 bytes, addressed directly: typedef unsigned ...

Page 39

Software User’s Guide Type definitions for internal data, 256 bytes, in the upper 128 bytes addressed indirectly: typedef unsigned char idata typedef unsigned short idata typedef unsigned long idata typedef signed char idata typedef signed short idata typedef signed ...

Page 40

Note: Throughout the Demo Code, an attempt has been made to put the most frequently used variables in the fastest memory space. Data Type Bit Sbit SFR SFR16 signed/unsigned char enum unsigned short signed short signed/unsigned int signed int unsigned ...

Page 41

Software User’s Guide There is a known defect in version 7.50a of the Keil compiler: Memory types must be explicitly defined in local variables. Using a predefined type is not explicit enough, i.e. "char xdata c;" is ok. "typedef ...

Page 42

Feature Code 8KB Size CT and shunt 1KB to Y resistors 2.5KB Rogowski coils 2.5KB N Feature Code 8KB Size Chopping of 0.06KB Y VREF Temperature 0.1KB Y compensation of VREF RTC compensa- 0.2KB N/opt tion using mains frequency RTC ...

Page 43

Software User’s Guide Feature Code 8KB Size Wh equation 1 0.2KB N Wh equation 2 0.2KB N/opt Frequency 0.1KB N register Wh net metering 0.4KB N Wh export register 0.25KB N Wh export pulse 0.25KB N output VARh register ...

Page 44

Feature Code 8KB Size Creep mode 0.37KB Y Zero accumulator N Current threshold N/A Y Voltage threshold 0.12KB N Feature Code 8KB Size Brownout mode 0.1KB Y LCD mode 0.5KB Y Wake button 0.5KB Y Wake timer ...

Page 45

Software User’s Guide Feature Code 8KB Size FLAG interface 2.5KB N protocol Reception of 2.0KB Y calibration parameters via the serial interface Count of 01.KB Y calibrations since first cold reset. Auto-calibration 3.5KB N Command Line 14KB N Interface ...

Page 46

Feature Code 8KB Size Error recording 0.4KB N/opt and saving Microwire 0.2KB N/opt EEPROM I2C EEPROM 0.2KB Y Table 5-9: Calibration and Various Services 5.3 PROGRAM FLOW 5.3.1 Startup and Initialization The top-level functionality of the Demo Board is controlled ...

Page 47

Software User’s Guide 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 ...

Page 48

Initialize battery mode management Remove software watchdogs Reset RTC Set default values Restore calibration values restore OK? yes autocal request? yes Perform autocal Revision 1.7 © Copyright 2005-2007 TERIDIAN Semiconductor Corporation no Apply calibration defaults no Figure 5-4: main_init() ...

Page 49

Software User’s Guide main_run() main_background() Command pending? yes Process command Process flag protocol (0) Process flag protocol (1) END 5.4 BASIC CODE ARCHITECTURE The TERIDIAN 71M652X firmware can be divided into two code parts. One is the Background task ...

Page 50

Foreground There are total 12 interrupts available for the 80515, and the revision 4.7a Demo Code uses a total of 11 interrupts. Table 5-10 shows the interrupt service routines (ISRs), the corresponding vectors (Table 6-58 in section 6.3.5.4) and ...

Page 51

Software User’s Guide the interrupt of the EEPROM (external interrupt 5), currently unused (code is available in Io\eeprom.c). Timer 0 shares its interrupt priority bits with FWCOL, the flash write timing interrupt, also unused (flash code is in Util\flash.c). ...

Page 52

Restart timer? yes Reload with TH0, TL0 no application needs timer0? yes Reset tmr0 SW watchdog END stm_run() tick_cnt<>0 pTimers = &Timers[NUM_TIMERS NUM_TIMERS Timer present Timer expired? N Timer expired function? execute Timer expired ...

Page 53

Software User’s Guide CE_BUSY Interrupt CE_BUSY interrupt is used for handling the outputs of the CE that are refreshed every 396µs, i.e. SAG detection. END XFER_BUSY and RTC Interrupt The XFER Busy interrupt is requested by the CE at ...

Page 54

The interrupt service routine includes a loop. Without this loop, there is the chance of a rare, subtle timing error because interrupt EXT6 is edge-triggered and the two interrupt sources "or" into it. The timing error will occur if the ...

Page 55

Software User’s Guide RTC interrupt happens, and then the XFER interrupt happens after the IE_XFER flag is already tested, but before the RTC interrupt is cleared. In this case, the signal to EXT6 will remain set, and never have ...

Page 56

Background Tasks meter_run() meter_run() no xfer_update = TRUE? yes gain_compensation() Compute_RMS() Wh_accumulate() VARh_accumulate() VAh_accumulate() SelectPulses() Revision 1.7 © Copyright 2005-2007 TERIDIAN Semiconductor Corporation 71M652X Software User’s Guide Compute_Phase_Angle() Determine_Frequency() RTC_Compensation () Determine_Peaks () Calc_Voltage_Phase () Calculate operating time no ...

Page 57

Software User’s Guide meter_LCD meter_lcd() ce_active = FALSE & RTC_Tic() =TRUE? yes LCD Clear Display " CE OFF" meter_totals (select_total, select_phase) display selected quantity on LCD END Revision 1.7 © Copyright 2005-2007 TERIDIAN Semiconductor Corporation no no ce_totals_rdy() = ...

Page 58

Command Line Interpreter cli() U08 data d; cli_result = NULL N cli_result = NULL & done(&d) = FALSE? Y toupper(d) = '/' ? N toupper(d) = ']' ? N toupper(d) = ')' ? N toupper( toupper(d) ...

Page 59

Software User’s Guide Auto-Calibration The auto-calibration option (not compiled in the executable Demo Code simplified calibration procedure based on voltage, real energy and reactive energy measurements. Before the calibration starts, the desired accumulation time (SCAL) and the ...

Page 60

If 0 <= cs <= Scal: For two accumulation intervals, prorated measurements of current and voltage are added to the variables. Using two accumulation intervals covers both chop polarities of temperature measurements This signals ...

Page 61

Software User’s Guide set_tc1_tc2() temperature compensation for adc fppmc1 = ppmc1 from CE fppmc2 = ppmc2 from calibration temperature from CE a calibration temperature exists? tn==0? tppmc1 = 0; tppmc2 = 0; no temperature compensation N ...

Page 62

Command Pending cmd_pending() N len = 0? no entry Y N !(len = Serial_CRx (port, cb, CMD_BUFF_SIZE)) Y return (FALSE) UART0 echo echo0 len < ...

Page 63

Software User’s Guide EEPROM Read/Write EEDATA= 0xA1 (read command) EECTRL = 0x03 (transmit data command) interrupt rcvd? (INT5) EECTRL = 0x06 (receive data command) interrupt rcvd? (INT5) *source = EEDATA (store data) Revision 1.7 © Copyright 2005-2007 TERIDIAN Semiconductor ...

Page 64

Registers and memory locations: • EEDATA = SFR 0x9E • EECTRL = SFR 0x9F • *source = pointer to EEPROM address for read or write • *destination = pointer to XRAM address • count = byte count for multiple read/write ...

Page 65

Software User’s Guide Start count==0? EECTRL = 0x05 (stop command) Clear all registers End Notes: • For larger EEPROMs, 1010xxR can be the first command (R=1 for read for write operation). • The START command should ...

Page 66

Power Factor Measurement The power-factor option (not compiled in the executable Demo Code) provides both instantaneous and accumulated (over fractions of an hour) display of power factor by phase. All power factor calculations are performed using floating point variables. The ...

Page 67

Software User’s Guide 5.5 MANAGING MISSION AND BATTERY MODES After a reset or power up, the processor must first decide what mode and then take the appropriate action useful to concentrate all activities related ...

Page 68

Precautions when adding a battery: When a battery or other DC supply is added to a Demo Board that is powered down, the 71M6521 Demo Code will cause the chip to enter Brownout mode and stay in Brownout mode. It ...

Page 69

Software User’s Guide At the end of each accumulation interval, an MPU interrupt, the "xfer_interrupt" occurs (see ce.c, xfer_busy_isr()) occurs. This is the signal for the MPU to copy the above data to stable storage for further use. At ...

Page 70

When compiled without the on-line help option (help.c), CLI.C takes about 14Kbytes of program space. Adding the on-line help will use another 5Kbytes. When designing a real meter, CLI.C can easily be removed without major changes to the software. 2. ...

Page 71

Software User’s Guide flag0test.c a test for a FLAG system modetest.c a simple test of the 6520’s battery modes ser0test.c tests the serial driver for SER0 ser1test.c tests the serial driver for SER1 stmtest.c tests the software timers tmr0test.c ...

Page 72

INCLUDE/HEADER FILES In line with common industry practice, each C file in the Demo Code source code has a corresponding header file that ends in .H and that provides the interface to the C file’s code. A number of ...

Page 73

Software User’s Guide 5.11.3 Other Include/Header Files Other Include/Header files are: • CLI.H - Result code and Common ASCII code definition used for CLI • HELP.H - HELP message prototype declarations • IO.H – I/O subroutines for CLI • ...

Page 74

CE IMAGE FILES The CE code uses pre-designed, pre-validated algorithms and calculations, which are accurate to the noise floor of the integrated circuit, saving substantial engineering and development time. The source code for the CE is proprietary. Only the ...

Page 75

Software User’s Guide Name Purpose IThrshldA Starting current, element A Config Configure meter operation on the fly. VPThrshld error if exceeded.* IPThrshld error if exceeded.* Y_Cal_Deg0 RTC adjust Y_Cal_Deg1 RTC adjust, linear by temp.* Y_Cal_Deg2 RTC adjust, squared by ...

Page 76

Name Purpose Ical Current value to be used for autocalibra- tion** VThrshld Voltage at which to measure frequency, zero crossing, etc. PulseWidth Maximum time pulse is on. temp_nom Nominal tempera- ture, the temperature at which calibration occurs. ImaxB Scaling maximum ...

Page 77

Software User’s Guide Name Purpose Vrms_A Vrms, element A Irms_A Irms, element A Vrms_B Vrms, element B**,† Irms_B Irms, element B STATUS Status of meter CAI Count of accumula- tion intervals since reset, or last clear. Whi** Imported Wh, ...

Page 78

Name Purpose Whn Net metered Wh, all elements A, Whn_A* Net metered Wh, element A, for autocalibration Whn_B* Net metered Wh, element B, for autocalibration VARhn* Net metered VARh, all elements VARhn_A* Net metered VARh, element A, for auto- calibration ...

Page 79

Software User’s Guide 5.14 FIRMWARE APPLICATION INFORMATION 5.14.1 Sag Detection A sag is defined as an undervoltage condition that persists for more than one period. A shorter undervoltage condition is called a dip (see Figure Figure 5-22). The occurrence ...

Page 80

Temperature Compensation for Measurements The internal voltage reference of the 652X ICs is calibrated during device manufacture. Trim data is stored in on-chip fuses. The temperature coefficients TC1 and TC2 are given as constants that represent typical component behavior. ...

Page 81

Software User’s Guide One method to correct the temperature characteristics of the crystal is to obtain coefficients from the curve in Figure 31 by curve-fitting the PPM deviations A fairly close curve fit is achieved with the coefficients a ...

Page 82

ALPHABETICAL FUNCTION REFERENCE Function/Routine Description Name x = abs(x0); Take absolute abs_x() value of n-byte 'x0 where 'x' & 'y' are add() 'n' bytes wide where 'x' is 'n' bytes add_1() wide, 'y' ...

Page 83

Software User’s Guide Function/Routine Description Name processes measurements calibrate() during auto-calibration returns CE status ce_active() Enables or disables the CE ce_enable() Initializes the CE ce_init() resets the CE ce_reset() command Line Interpreter cli () Initializes the SLI's interface cli_init() ...

Page 84

Function/Routine Description Name calculates longitudinal parity LRC_Calc_NVR() on NVRAM converts ascii hex character ctoh() to hexadecimal digit Displays the current date. date_lcd () Figure the elapsed time Delta_Time () between two times. Sets the frequency. Uses sag status and voltage ...

Page 85

Software User’s Guide Function/Routine Description Name Output interrupt for FLAG flag1_out() AMR module on SER1 Run main loop logic for FLAG AMR module on flag1_run() SER1 Displays the frequency on frequency_lcd () the LCD. Copies CE configuration constants to ...

Page 86

Function/Routine Description Name IIC bus's start condition IICStart() IIC bus's stop condition IICStop() Initializes meter to default init_meter() values Defines variables used by macros to enable and IRQ_DEFINES disable interrupts. Disables interrupts. irq_disable() The fastest way to disable interrupts. Requires ...

Page 87

Software User’s Guide Function/Routine Description Name Displays a number on the LCD_Number() LCD. returns maximum of lmax() unsigned long 'a' and 'b'. returns minimum of lmin() unsigned long 'a' and 'b'. returns binary logarithm log2() executes background main_background() processing ...

Page 88

Function/Routine Description Name compares xdata to xdata memcmp_xx() copies xdata to idata memcpy_ix() Copies data to serial memcpy_px() EEPROM reads from or writes to flash memcpy_rce() Copies xdata to code (flash) memcpy_rx() Copies idata to xdata memcpy_xi() copies data from ...

Page 89

Software User’s Guide Function/Routine Description Name puts a register into normal form, in which the major count greater than or equal to zero, and less than 1,000,000,000. The minor count of ce counts normalize() (e.g. from ...

Page 90

Function/Routine Description Name The inputs are watt hours, as generated by the CE, and set the extra pulse generators to blink at the same rate as CE pulse out- psoft_update () puts, with the same units. This should be called ...

Page 91

Software User’s Guide Function/Routine Description Name sends text in code at specified location to serial send_help() port sends byte out SERIAL0 in send_hex() HEX sends a [0, 9,999,999,999] send_long() value to DTE. sends a [0, FFFFFFFF] send_long_hex() value to ...

Page 92

Function/Routine Description Name Returns true if the serial ser_xmit_rdy() port can send another byte. Receive a string Serial_CRx() maximum length. Transmit a string Serial_CTx() maximum length. gets additional bytes from Serial_CRx() the receive buffer ...

Page 93

Software User’s Guide Function/Routine Description Name Transmit a string Serial1_CTx() maximum length. Receive a string of any Serial1_Rx() length. Force an XOFF to be sent Serial1_RxFlowOff( on this port. ) Force an XON to be sent ...

Page 94

Function/Routine Description Name Waits for the passed stm_wait() number of clock ticks. returns length of string in strlen_r () flash code returns length of string in strlen_x() xdata (uint64_t (uint32_t) y sub8_4() (uint64_t (uint64_t) y sub8_8() ...

Page 95

Software User’s Guide Function/Routine Description Name Calculates VAh VAh_Accumulate() Calculates VARh VARh_Accumulate() Display voltage phases on voltage_phase_lcd( LCD. ) Creates a software wd_create() watchdog. Destroys a software wd_destroy() watchdog. Resets a software watch- dog. If all software watch- wd_reset() ...

Page 96

PORTING 71M6511/6513 CODE TO THE 71M6521 5.17.1 Memory Use The biggest issue when moving code from the 6511/6513 to the 71M6521 is the reduced program memory. While the 71M6511 and 6513 have 64K, the 6521 has 32K, 16K and ...

Page 97

Software User’s Guide V3P3SYS rises LCD_ONLY IE_PB -> LCD VBAT _OK Figure 5-26: Operation Modes State Diagram The wake-up timer is a little trickier to use than the pushbutton. To use it, one must first write the ...

Page 98

The demo software is designed so that the serial port always runs at 300 bd, in both mission mode and brownout mode. The 6521 has special clock-interpolation logic in the baud rate generation so that 300 baud works in brownout ...

Page 99

... Serial Port Tests These Test Modules build simple tests of the serial ports. The tests start by sending the ASCII character "E" loop, e.g. For testing with an oscilloscope. characters, using polling IO. Sending the period character ( ".") switches the I/O to interrupting I/O. ...

Page 100

The Keil project file is RESET_READ_SE.UV2. 5.18.7 Software Timer Test This project, consisting of several files, demonstrates the use and test of the software timer using a hardware timer that is multiplexed into many slower timers. The Keil project file ...

Page 101

Software User’s Guide 6 80515 MPU REFERENCE An 80515 core is implemented on the TERIDIAN 71M652X chips. This section is intended for software engineers who plan to use the 80515. 6.1 80515 OVERVIEW The 80515 is a fast single-chip ...

Page 102

Features Below is a summary of the 80515 features: ♦ Control Unit 8-bit instruction decoder Reduced instruction cycle time times ♦ Arithmetic-Logic Unit 8 bit arithmetic and logical operations Boolean manipulations bit ...

Page 103

Software User’s Guide 6.2 80515 ARCHITECTURAL OVERVIEW 6.2.1 Memory organization The 80515 MPU core incorporates the Harvard architecture with separate code and data spaces. Memory organization in the 80515 is similar to that of the industry standard 8051. There ...

Page 104

CKCON register CKCON.2 CKCON.1 CKCON Table 6-2: Stretch Memory Cycle Width There are two types of ...

Page 105

Software User’s Guide Address Direct addressing 0xFF Special Function 0x80 Registers (SFRs) 0x7F 0x30 0x2F 0x20 0x1F 0x00 Special Function Registers Location A map of the Special Function Registers is shown in Table 6-4. Only a few addresses are ...

Page 106

Generic Special Function Register Overview All generic SFRs are explained in detail in section 6.3.2. Register Symbol Program status PSW word Accumulator ACC B register B Stack pointer SP Data pointer DPL, DPH Secondary data DPL1, DPH1 pointer Data pointer ...

Page 107

Software User’s Guide Generic Special Function Registers Location and Reset Values Table 6-5 shows the location of the SFRs and the value they assume at reset or power-up. Register Location Reset value P0 80H FFH SP 81H 07H DPL ...

Page 108

Special Function Registers Specific to the 652X Register Alternative SFR Name Address DIO0 DIO_0 0x80 DIO8 DIO_DIR0 0xA2 DIO9 DIO_1 0x90 DIO10 DIO_DIR1 0x91 DIO11 DIO_2 0xA0 DIO12 DIO_DIR2 0xA1 ERASE FLSH_ERASE 0x94 PGADDR FLSH_PGADR 0xB7 EEDATA 0x9E EECTRL 0x9F ...

Page 109

Software User’s Guide WDI 0xE8 INTBITS INT0…INT6 0xF8 6.2.2 The 80515 Instruction Set All 80515 instructions are binary code compatible and perform the same functions as they do with the industry standard 8051. The following tables give a summary ...

Page 110

Instructions Ordered by Function Mnemonic Description ADD A,Rn Add register to accumulator ADD A,direct Add direct byte to accumulator ADD A,@Ri Add indirect RAM to accumulator ADD A,#data Add immediate data to accumulator ADDC A,Rn Add register to accumulator with ...

Page 111

Software User’s Guide Mnemonic Description ANL A,Rn AND register to accumulator ANL A,direct AND direct byte to accumulator ANL A,@Ri AND indirect RAM to accumulator ANL A,#data AND immediate data to accumulator ANL direct,A AND accumulator to direct byte ...

Page 112

Mnemonic Description MOV A,Rn Move register to accumulator MOV A,direct Move direct byte to accumulator MOV A,@Ri Move indirect RAM to accumulator MOV A,#data Move immediate data to accumulator MOV Rn,A Move accumulator to register MOV Rn,direct Move direct byte ...

Page 113

Software User’s Guide Mnemonic Description ACALL addr11 Absolute subroutine call LCALL addr16 Long subroutine call RET Return from subroutine RETI Return from interrupt AJMP addr11 Absolute jump LJMP addr16 Long jump SJMP rel Short jump (relative addr.) JMP @A+DPTR ...

Page 114

Instructions Ordered by Opcode (Hexadecimal) Opcode Mnemonic 0x00 NOP 0x01 AJMP addr11 0x02 LJMP addr16 0x03 RR A 0x04 INC A 0x05 INC direct 0x06 INC @R0 0x07 INC @R1 0x08 INC R0 0x09 INC R1 0x0A INC R2 0x0B ...

Page 115

Software User’s Guide Opcode Mnemonic 0x60 JZ rel 0x61 AJMP addr11 0x62 XRL direct,A 0x63 XRL direct,#data 0x64 XRL A,#data 0x65 XRL A,direct 0x66 XRL A,@R0 0x67 XRL A,@R1 0x68 XRL A,R0 0x69 XRL A,R1 0x6A XRL A,R2 0x6B ...

Page 116

Opcode 0xC0 0xC1 0xC2 0xC3 0xC4 0xC5 0xC6 0xC7 0xC8 0xC9 0xCA 0xCB 0xCC 0xCD 0xCE 0xCF 0xE0 0xE1 0xE2 0xE3 0xE4 0xE5 0xE6 0xE7 0xE8 0xE9 0xEA 0xEB 0xEC 0xED 0xEE 0xEF Table 6-16: Instruction Set in Hexadecimal Order ...

Page 117

Software User’s Guide Instructions that Affect Flags Affected Flag Instruction C ADD X ADDC X SUBB X MUL 0 DIV RRC X RLC X SETB C 1 Table 6-17: Instructions Affecting Flags Note: Operations affecting the ...

Page 118

Block Diagram MEMORY_CONTROL to/from pc XRAMs & dptr Prog dptr1 Mem fetch instr CONTROL_UNIT instrreg fetch instr RAM_SFR_CONTROL sp to/from IRAM & SFRs instr ALU acc rxd0i SERIAL_0 rxd0o s0rell s0relh txd0 rxd1i SERIAL_1 txd1 s1rell s1relh CLOCK_CONTROL pcon ...

Page 119

Software User’s Guide 6.3.2 80515 MPU The 80515 MPU is composed of four components: 1. Control unit 2. Arithmetic-logic unit 3. Memory control unit 4. RAM and SFR control unit The 80515 MPU allows instruction fetch from program memory ...

Page 120

The state of bits RS1 and RS0 select the working registers bank as follows: RS1/RS0 Stack Pointer The stack pointer is a 1-byte register initialized to 07H after reset. This register is incremented before PUSH and ...

Page 121

Software User’s Guide Timer/Counter Mode Control Register (TMOD) MSB GATE C/T Timer 1 Bit Symbol Function TMOD.7 Gate If set, enables external gate control (pin int0 or int1 for Counter respectively). When int0 or int1 is ...

Page 122

Bit Symbol Function The Timer 1 overflow flag is set by hardware when Timer 1 overflows. This flag TCON.7 TF1 can be cleared by software and is automatically cleared when an interrupt is processed. TCON.6 TR1 Timer 1 Run control ...

Page 123

Software User’s Guide Mode 1 Pin rxd0 serves as an input, and txd0 serves as a serial output. No external shift clock is used. 10 bits are transmitted: a start bit (always 0), 8 data bits (LSB first), and ...

Page 124

SM0 SM1 Note: The speed in Mode 2 depends on the SMOD bit in the Special Function Register PCON when SMOD = 1, Fclk/32. Serial Interface 1 Modes The Serial Interface 1 ...

Page 125

Software User’s Guide Bit Symbol Function S1CON.7 SM Sets baud rate S1CON.5 SM21 Enables the multiprocessor communication feature (see description above). S1CON.4 REN1 If set, enables serial reception. Cleared by software to disable reception. S1CON.3 TB81 The 9 depending ...

Page 126

Software Watchdog Timer The watchdog timer is a 16-bit counter that is incremented once every 24 or 384 clock cycles. After an external reset, the watchdog timer is disabled and all registers are set to zero. Software Watchdog Timer ...

Page 127

Software User’s Guide Refreshing the WD Timer The watchdog timer must be refreshed regularly to prevent the reset request signal from becoming active. This re- quirement imposes an obligation on the programmer to issue two instructions. The first instruction ...

Page 128

IP0.6 WDTS Watchdog timer status flag. Set by hardware when the watchdog timer was started. Can be read by software. Note: The remaining bits in the IP0 register are not used for watchdog control Watchdog Timer Reload Register (WDTREL): MSB ...

Page 129

Software User’s Guide EAL WDT Bit Symbol Function IEN0.7 EAL EAL=0 – disable all interrupts IEN0.6 WDT Not used for interrupt control IEN0.5 - IEN0.4 ES0 ES0=0 – disable UART 0 interrupt IEN0.3 ET1 ET1=0 – disable timer 1 ...

Page 130

Timer/Counter Control Register (TCON) MSB TF1 TR1 Bit Symbol Function TCON.7 TF1 Timer 1 overflow flag TCON.6 TR1 Not used for interrupt control TCON.5 TF0 Timer 0 overflow flag TCON.4 TR0 Not used for interrupt control TCON.3 IE1 External interrupt ...

Page 131

Software User’s Guide Interrupt Request register (T2CON) MSB I3FR Bit Symbol T2CON.7 T2CON.6 I3FR This bit controls the polarity of external interrupt 3 T2CON.5 I2FR This bit controls the polarity of external interrupt 2 T2CON.4 T2CON.3 T2CON.2 T2CON.1 T2CON.0 ...

Page 132

Comparator 5 EEPROM busy 6 XFER_BUSY OR RTC_1SEC Enable Bit Description EX0 Enable external interrupt 0 EX1 Enable external interrupt 1 EX2 Enable external interrupt 2 EX3 Enable external interrupt 3 EX4 Enable external interrupt 4 EX5 Enable external ...

Page 133

Software User’s Guide 6.3.5.5 Interrupt Sources and Vectors The vectors associated with each interrupt source are displayed in Table 6-59. Interrupt Request Flags IE0 – External interrupt 0 TF0 – Timer 0 interrupt IE1 – External interrupt 1 TF1 ...

Page 134

External Int ernal I nterrupt Int errupt Sourc e Flags F lags UART1 (optical Tim Com par ...

Page 135

Software User’s Guide 7 APPENDIX 7.1 ACRONYMS AC Alternating Current – current with changing polarity AMR Automated Meter Reading, usually performed via an optical port or modem ANSI American National Standardization Institution, part of ISO ANSI C C Programming ...

Page 136

LSB Least Significant Bit MB Megabyte(s) – 1,024 kilobytes MPU Microprocessor/microcontroller Unit MSB Most Siginificant Bit NV Non-Volatile PC Personal Computer, Program Counter PSU Power Supply Unit PSW Program Status Word RAM Random Access Memory SFR Special Function Register (of ...

Page 137

Software User’s Guide Revision 1.7 © Copyright 2005-2007 TERIDIAN Semiconductor Corporation TERIDIAN Proprietary 137 of 138 ...

Page 138

Software User Guide: This User Guide contains proprietary product definition information of TERIDIAN Semiconductor Corporation (TSC) and is made available for informational purposes only. TERIDIAN assumes no obligation regarding future manufacture, unless agreed to in writing. If and when manufactured ...

Related keywords