以下啟動程序用來替代startup.a51,Maxim提供經(jīng)過測試的軟件代碼(4.8p演示軟件中,啟動程序位于utilstartup_n_safe.a51),以下列出了程序代碼。
第一次在工廠運行程序時,微調(diào)寄存器的內(nèi)容被復(fù)制到閃存內(nèi)。之后,對微調(diào)寄存器進行測試。一旦測試中發(fā)生失效,程序?qū)⒑唵蔚匕袸C置于休眠模式,然后重新讀取微調(diào)數(shù)據(jù)。喚醒器件操作后,IC會自動讀取微調(diào)“保險絲”內(nèi)的數(shù)值。復(fù)位期間調(diào)用保險絲測試程序,將重新讀取微調(diào)“保險絲”的數(shù)據(jù)并進行修正。
?
;/*************************************************************************** ; * This code and information is provided "as is" without warranty of any * ; * kind, either expressed or implied, including but not limited to the * ; * implied warranties of merchantability and/or fitness for a particular * ; * purpose. * ; * * ; * Copyright (C) 2011 Maxim Integrated Products, Inc. All Rights Reserved. * ; ***************************************************************************/ ;//************************************************************************** ;// ;// DESCRIPTION: 71M652x POWER METER - STARTUP Code. ;// ;//************************************************************************** ;// ;// File: STARTUP_N_SAFE.A51. ;// $NOMOD51 ;------------------------------------------------------------------------------ ; This file is part of the C51 Compiler package ; Copyright (c) 1988-2002 Keil Elektronik GmbH and Keil Software, Inc. ;------------------------------------------------------------------------------ ; STARTUP.A51: This code is executed after processor reset. ; ; To translate this file use A51 with the following invocation: ; ; A51 STARTUP_N_SAFE.A51 ; ; To link the modified STARTUP_N_SAFE.OBJ file to your application use the following ; BL51 invocation: ; ; BL51, STARTUP_N_SAFE.OBJ ; ;------------------------------------------------------------------------------ ; ; User-defined Power-On Initialization of Memory ; With the following EQU statements the initialization of memory ; at processor reset can be defined: ; ; ; the absolute start-address of IDATA memory is always 0 IDATALEN EQU 100H ; the length of IDATA memory in bytes. ; XDATASTART EQU 0H ; the absolute start-address of XDATA memory XDATALEN EQU 000H ; the length of XDATA memory in bytes. ; PDATASTART EQU 0H ; the absolute start-address of PDATA memory PDATALEN EQU 0H ; the length of PDATA memory in bytes. ; ; Notes: The IDATA space overlaps physically the DATA and BIT areas of the ; 8051 CPU. At minimum the memory space occupied from the C51 ; run-time routines must be set to zero. ;------------------------------------------------------------------------------ ; ; Reentrant Stack Initialization ; ; The following EQU statements define the stack pointer for reentrant ; functions and initialized it: ; ; Stack Space for reentrant functions in the SMALL model. IBPSTACK EQU 1 ; set to 1 if small reentrant is used. IBPSTACKTOP EQU 0FFH+1 ; set top of stack to highest location+1. ; ; Stack Space for reentrant functions in the LARGE model. XBPSTACK EQU 0 ; set to 1 if large reentrant is used. XBPSTACKTOP EQU 07FFH+1; set top of stack to highest location+1. ; ; Stack Space for reentrant functions in the COMPACT model. PBPSTACK EQU 0 ; set to 1 if compact reentrant is used. PBPSTACKTOP EQU 07FFH+1; set top of stack to highest location+1. ; ;------------------------------------------------------------------------------ ; Page Definition for Using the Compact Model with 64 KByte xdata RAM ; ; The following EQU statements define the xdata page used for pdata ; variables. The EQU PPAGE must conform with the PPAGE control used ; in the linker invocation. ; PPAGEENABLE EQU 1 ; set to 1 if pdata object are used. ; PPAGE EQU 7 ; define PPAGE number. PUBLIC PPAGE_SFR PPAGE_SFR DATA 0BFH ; SFR that supplies uppermost address byte ; (most 8051 variants use P2 as uppermost address byte) ;------------------------------------------------------------------------------ ; Switch to M6520 when chip is available. ; Standard SFR Symbols ACC DATA 0E0H B DATA 0F0H SP DATA 81H DPL DATA 82H DPH DATA 83H USER1 DATA 90H DIR1 DATA 91H FCTRL DATA 0B2H IPH DATA 0B9H IPL DATA 0A9H IRCON DATA 0C0H IEN0 DATA 0A8H IEN1 DATA 0B8H NAME ?C_STARTUP ?C_C51STARTUP SEGMENT CODE ?STACK SEGMENT IDATA RSEG ?STACK DS 1 EXTRN CODE (?C_START) PUBLIC ?C_STARTUP PUBLIC _?TRIM_TEST CSEG AT 0 ?C_STARTUP: LJMP STARTUP1 RSEG ?C_C51STARTUP STARTUP1: CLR IEN0^7 ; Disable interrupts ; To enable secure mode, remove the semicolon of the next line ; ORL FCTRL,#40H ; set secure bit MOV 0E8h,#0FFh ; Refresh nonmaskable watchdog. ; Set system interrupt priorities; more frequent are higher priority. MOV IPH,#01DH ; From code in options_gbl.h, main.c MOV IPL,#00AH ; From code in options_gbl.h ; Clear PLL_OK interrupt (bit3), and others MOV IRCON,#0 ; Enable PLL_OK interrupt MOV DPTR,#2007H ; Set EX_PLL MOV A,#20H MOVX @DPTR,A ; Enable interrupts MOV IEN1,#08H ; Enable INT4, the PLL_OK interrupt MOV IEN0,#80H ; Enable all interrupts ACALL _?TRIM_TEST ; Test 6521's trims IF IDATALEN <> 0 MOV R0,#IDATALEN - 1 CLR A IDATALOOP: MOV @R0,A DJNZ R0,IDATALOOP ENDIF
評論