📄 boot.asm
字号:
; Generated by PSoC Designer ver 4.4 b1884 : 14 Jan, 2007
;
;@Id: boot.tpl#851 @
;=============================================================================
; FILENAME: boot.asm
; VERSION: 4.18
; DATE: 28 June 2007
;
; DESCRIPTION:
; M8C Boot Code for CY8C29xxx microcontroller family.
;
; Copyright (C) Cypress Semiconductor 2000-2005. All rights reserved.
;
; NOTES:
; PSoC Designer's Device Editor uses a template file, BOOT.TPL, located in
; the project's root directory to create BOOT.ASM. Any changes made to
; BOOT.ASM will be overwritten every time the project is generated; therfore
; changes should be made to BOOT.TPL not BOOT.ASM. Care must be taken when
; modifying BOOT.TPL so that replacement strings (such as @PROJECT_NAME)
; are not accidentally modified.
;
;=============================================================================
include ".\lib\GlobalParams.inc"
include "m8c.inc"
include "m8ssc.inc"
include "memory.inc"
;--------------------------------------
; Export Declarations
;--------------------------------------
export __Start
IF (TOOLCHAIN & HITECH)
ELSE
export __bss_start
export __data_start
export __idata_start
export __func_lit_start
export __text_start
ENDIF
export _bGetPowerSetting
export bGetPowerSetting
;--------------------------------------
; Optimization flags
;--------------------------------------
;
; To change the value of these flags, modify the file boot.tpl, not
; boot.asm. See the notes in the banner comment at the beginning of
; this file.
; Optimization for Assembly language (only) projects and C-language projects
; that do not depend on the C compiler to initialize the values of RAM variables.
; Set to 1: Support for C Run-time Environment initialization
; Set to 0: Support for C not included. Faster start up, smaller code space.
;
IF (TOOLCHAIN & HITECH)
; The C compiler will customize the startup code - it's not required here
C_LANGUAGE_SUPPORT: equ 0
ELSE
C_LANGUAGE_SUPPORT: equ 1
ENDIF
; The following equate is required for proper operation. Reseting its value
; is discouraged. WAIT_FOR_32K is effective only if the crystal oscillator is
; selected. If the designer chooses to not wait then stabilization of the ECO
; and PLL_Lock must take place within user code. See the family data sheet for
; the requirements of starting the ECO and PLL lock mode.
;
; Set to 1: Wait for XTAL (& PLL if selected) to stabilize before
; invoking main
; Set to 0: Boot code does not wait; clock may not have stabilized by
; the time code in main starts executing.
;
WAIT_FOR_32K: equ 1
; For historical reasons, by default the boot code uses an lcall instruction
; to invoke the user's _main code. If _main executes a return instruction,
; boot provides an infinite loop. By changing the following equate from zero
; to 1, boot's lcall will be replaced by a ljmp instruction, saving two
; bytes on the stack which are otherwise required for the return address. If
; this option is enabled, _main must not return. (Beginning with the 4.2
; release, the C compiler automatically places an infinite loop at the end
; of main, rather than a return instruction.)
;
ENABLE_LJMP_TO_MAIN: equ 0
;-----------------------------------------------------------------------------
; Interrupt Vector Table
;-----------------------------------------------------------------------------
;
; Interrupt vector table entries are 4 bytes long. Each one contains
; a jump instruction to an ISR (Interrupt Service Routine), although
; very short ISRs could be encoded within the table itself. Normally,
; vector jump targets are modified automatically according to the user
; modules selected. This occurs when the 'Generate Application' opera-
; tion is run causing PSoC Designer to create boot.asm and the other
; configuration files. If you need to hard code a vector, update the
; file boot.tpl, not boot.asm. See the banner comment at the beginning
; of this file.
;-----------------------------------------------------------------------------
AREA TOP (ROM, ABS, CON)
org 0 ;Reset Interrupt Vector
IF (TOOLCHAIN & HITECH)
; jmp __Start ;C compiler fills in this vector
ELSE
jmp __Start ;First instruction executed following a Reset
ENDIF
org 04h ;Supply Monitor Interrupt Vector
halt ;Stop execution if power falls too low
org 08h ;Analog Column 0 Interrupt Vector
// call void_handler
reti
org 0Ch ;Analog Column 1 Interrupt Vector
// call void_handler
reti
org 10h ;Analog Column 2 Interrupt Vector
// call void_handler
reti
org 14h ;Analog Column 3 Interrupt Vector
// call void_handler
reti
org 18h ;VC3 Interrupt Vector
// call void_handler
reti
org 1Ch ;GPIO Interrupt Vector
ljmp PSoC_GPIO_ISR
reti
org 20h ;PSoC Block DBB00 Interrupt Vector
// call void_handler
reti
org 24h ;PSoC Block DBB01 Interrupt Vector
// call void_handler
reti
org 28h ;PSoC Block DCB02 Interrupt Vector
// call void_handler
reti
org 2Ch ;PSoC Block DCB03 Interrupt Vector
// call void_handler
reti
org 30h ;PSoC Block DBB10 Interrupt Vector
// call void_handler
reti
org 34h ;PSoC Block DBB11 Interrupt Vector
// call void_handler
reti
org 38h ;PSoC Block DCB12 Interrupt Vector
// call void_handler
reti
org 3Ch ;PSoC Block DCB13 Interrupt Vector
// call void_handler
reti
org 40h ;PSoC Block DBB20 Interrupt Vector
// call void_handler
reti
org 44h ;PSoC Block DBB21 Interrupt Vector
// call void_handler
reti
org 48h ;PSoC Block DCB22 Interrupt Vector
// call void_handler
reti
org 4Ch ;PSoC Block DCB23 Interrupt Vector
// call void_handler
reti
org 50h ;PSoC Block DBB30 Interrupt Vector
// call void_handler
reti
org 54h ;PSoC Block DBB31 Interrupt Vector
// call void_handler
reti
org 58h ;PSoC Block DCB32 Interrupt Vector
// call void_handler
reti
org 5Ch ;PSoC Block DCB33 Interrupt Vector
// call void_handler
reti
org 60h ;PSoC I2C Interrupt Vector
// call void_handler
reti
org 64h ;Sleep Timer Interrupt Vector
// call void_handler
reti
;-----------------------------------------------------------------------------
; Start of Execution.
;-----------------------------------------------------------------------------
; The Supervisory ROM SWBootReset function has already completed the
; calibrate1 process, loading trim values for 5 volt operation.
;
IF (TOOLCHAIN & HITECH)
AREA PD_startup(CODE, REL, CON)
ELSE
org 68h
ENDIF
__Start:
; initialize SMP values for voltage stabilization, if required,
; leaving power-on reset (POR) level at the default (low) level, at
; least for now.
;
M8C_SetBank1
mov reg[VLT_CR], SWITCH_MODE_PUMP_JUST | LVD_TBEN_JUST | TRIP_VOLTAGE_JUST
M8C_SetBank0
; %53%20%46%46% Apply Erratum 001-05137 workaround
mov A, 20h
romx
mov A, 40h
romx
mov A, 60h
romx
; %45%20%46%46% End workaround
IF ( WATCHDOG_ENABLE ) ; WDT selected in Global Params
M8C_EnableWatchDog
ENDIF
IF ( SELECT_32K )
or reg[CPU_SCR1], CPU_SCR1_ECO_ALLOWED ; ECO will be used in this project
ELSE
and reg[CPU_SCR1], ~CPU_SCR1_ECO_ALLOWED ; Prevent ECO from being enabled
ENDIF
;---------------------------
; Set up the Temporary stack
;---------------------------
; A temporary stack is set up for the SSC instructions.
; The real stack start will be assigned later.
;
_stack_start: equ 80h
mov A, _stack_start ; Set top of stack to end of used RAM
swap SP, A ; This is only temporary if going to LMM
;-----------------------------------------------
; Set Power-related Trim & the AGND Bypass bit.
;-----------------------------------------------
IF ( POWER_SETTING & POWER_SET_5V0) ; *** 5.0 Volt operation ***
IF ( POWER_SETTING & POWER_SET_SLOW_IMO) ; *** 6MHZ Main Oscillator ***
or reg[CPU_SCR1], CPU_SCR1_SLIMO
M8SSC_Set2TableTrims 2, SSCTBL2_TRIM_IMO_5V_6MHZ, 1, SSCTBL1_TRIM_BGR_5V, AGND_BYPASS_JUST
ELSE ; *** 12MHZ Main Oscillator ***
IF ( AGND_BYPASS )
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; The 5V trim has already been set, but we need to update the AGNDBYP
; bit in the write-only BDG_TR register. Recalculate the register
; value using the proper trim values.
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
M8SSC_SetTableVoltageTrim 1, SSCTBL1_TRIM_BGR_5V, AGND_BYPASS_JUST
ENDIF
ENDIF
ENDIF ; 5.0 V Operation
IF ( POWER_SETTING & POWER_SET_3V3) ; *** 3.3 Volt operation ***
IF ( POWER_SETTING & POWER_SET_SLOW_IMO) ; *** 6MHZ Main Oscillator ***
or reg[CPU_SCR1], CPU_SCR1_SLIMO
M8SSC_Set2TableTrims 2, SSCTBL2_TRIM_IMO_3V_6MHZ, 1, SSCTBL1_TRIM_BGR_3V, AGND_BYPASS_JUST
ELSE ; *** 12MHZ Main Oscillator ***
M8SSC_SetTableTrims 1, SSCTBL1_TRIM_IMO_3V_24MHZ, SSCTBL1_TRIM_BGR_3V, AGND_BYPASS_JUST
ENDIF
ENDIF ; 3.3 Volt Operation
mov [bSSC_KEY1], 0 ; Lock out Flash and Supervisiory operations
mov [bSSC_KEYSP], 0
;---------------------------------------
; Initialize Crystal Oscillator and PLL
;---------------------------------------
IF ( SELECT_32K & WAIT_FOR_32K )
; If the user has requested the External Crystal Oscillator (ECO) then turn it
; on and wait for it to stabilize and the system to switch over to it. The PLL
; is left off. Set the SleepTimer period is set to 1 sec to time the wait for
; the ECO to stabilize.
;
M8C_SetBank1
mov reg[OSC_CR0], (SELECT_32K_JUST | OSC_CR0_SLEEP_1Hz | OSC_CR0_CPU_12MHz)
M8C_SetBank0
M8C_ClearWDTAndSleep ; Reset the sleep timer to get a full second
or reg[INT_MSK0], INT_MSK0_SLEEP ; Enable latching of SleepTimer interrupt
mov reg[INT_VC], 0 ; Clear all pending interrupts
.WaitFor1s:
tst reg[INT_CLR0], INT_MSK0_SLEEP ; Test the SleepTimer Interrupt Status
jz .WaitFor1s ; Interrupt will latch but will not dispatch
; since interrupts are not globally enabled
ELSE ; !( SELECT_32K & WAIT_FOR_32K )
; Either no ECO, or waiting for stable clock is to be done in main
M8C_SetBank1
mov reg[OSC_CR0], (SELECT_32K_JUST | PLL_MODE_JUST | SLEEP_TIMER_JUST | OSC_CR0_CPU_12MHz)
M8C_SetBank0
M8C_ClearWDTAndSleep ; Reset the watch dog
ENDIF ;( SELECT_32K & WAIT_FOR_32K )
IF ( PLL_MODE )
; Crystal is now fully operational (assuming WAIT_FOR_32K was enabled).
; Now start up PLL if selected, and wait 16 msec for it to stabilize.
;
M8C_SetBank1
mov reg[OSC_CR0], (SELECT_32K_JUST | PLL_MODE_JUST | OSC_CR0_SLEEP_64Hz | OSC_CR0_CPU_3MHz)
M8C_SetBank0
M8C_ClearWDTAndSleep ; Reset the sleep timer to get full period
mov reg[INT_VC], 0 ; Clear all pending interrupts
.WaitFor16ms:
tst reg[INT_CLR0],INT_MSK0_SLEEP ; Test the SleepTimer Interrupt Status
jz .WaitFor16ms
M8C_SetBank1 ; continue boot at CPU Speed of SYSCLK/2
mov reg[OSC_CR0], (SELECT_32K_JUST | PLL_MODE_JUST | OSC_CR0_SLEEP_64Hz | OSC_CR0_CPU_12MHz)
M8C_SetBank0
IF ( WAIT_FOR_32K )
ELSE ; !( WAIT_FOR_32K )
; Option settings (PLL-Yes, ECO-No) are incompatible - force a syntax error
ERROR_PSoC Disabling WAIT_FOR_32K requires that the PLL_Lock must be enabled in user code.
ENDIF ;(WAIT_FOR_32K)
ENDIF ;(PLL_MODE)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -