⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 boot.tpl

📁 Application Note Abstract The unique configuration of the PSoC&reg switched capacitor blocks allows
💻 TPL
📖 第 1 页 / 共 2 页
字号:
;@Id: boot.tpl#6 @
;=============================================================================
;  FILENAME:   boot.asm
;  VERSION:    3.20
;  DATE:       10 October 2002
;
;  DESCRIPTION:
;  M8C Boot Code from Reset.
;
;  Copyright (C) Cypress MicroSystems 2001, 2002. 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.
;
; The start of _main is at a fixed location so care must be taken when adding
; user code for any interrupts within boot.asm. If too much code is added,the 
; end of BOOT.ASM will extend into _main and cause a linker error. The safest
; way to add code for an interrupt is to LCALL or LJMP to a normal routine 
; located in a seperate file that contains the desired additional interrupt 
; code.
;=============================================================================

include ".\lib\`@PROJECT_NAME`_GlobalParams.inc"
include "m8c.inc"
include "m8ssc.inc"

;-----------------------------------------------------------------------------
; Optimization flags
;-----------------------------------------------------------------------------

C_LANGUAGE_SUPPORT: equ 1   ;Set to 0 to optimize for ASM only

;-----------------------------------------------------------------------------
; The following equate is required for proper operation. Reseting its value
; is discouraged.
;-----------------------------------------------------------------------------

WAIT_FOR_32K: equ 1         ; Wait for Crystal to start before allowing main()
                            ; Is effective only if the crystal oscillator is 
                            ; selected.  If the designer choses to not WAIT,
                            ; then the ECO and PLL_Lock process must be taken
                            ; care of with user code. 

;-----------------------------------------------------------------------------
; Export Declarations
;-----------------------------------------------------------------------------

export __Start
export __Exit
export __bss_start

export __lit_start
export __idata_start
export __data_start
export __func_lit_start
export __text_start


;-----------------------------------------------------------------------------
; Interrupt Vector Table
;-----------------------------------------------------------------------------
;
; Interrupt vector table entries are 4 bytes long and contain the code
; that services the interrupt (or causes it to be serviced).
;
;-----------------------------------------------------------------------------


    AREA    TOP(ROM, ABS)

    org 0                   ;Reset Interrupt Vector
    jmp __Start             ;First instruction executed following a Reset

    org 04h                 ;Supply Monitor Interrupt Vector
    halt                    ;Stop execution if power falls too low
    reti

    org 08h                 ;PSoC Block DBA00 Interrupt Vector
    `@INTERRUPT_2`
    reti

    org 0Ch                 ;PSoC Block DBA01 Interrupt Vector
    `@INTERRUPT_3`
    reti

    org 10h                 ;PSoC Block DBA02 Interrupt Vector
    `@INTERRUPT_4`
    reti

    org 14h                 ;PSoC Block DBA03 Interrupt Vector
    `@INTERRUPT_5`
    reti

    org 18h                 ;PSoC Block DCA04 Interrupt Vector
    `@INTERRUPT_6`
    reti

    org 1Ch                 ;PSoC Block DCA05 Interrupt Vector
    `@INTERRUPT_7`
    reti

    org 20h                 ;PSoC Block DCA06 Interrupt Vector
    `@INTERRUPT_8`
    reti

    org 24h                 ;PSoC Block DCA07 Interrupt Vector
    `@INTERRUPT_9`
    reti

    org 28h                 ;Analog Column 0 Interrupt Vector
    `@INTERRUPT_10`
    reti

    org 2Ch                 ;Analog Column 1 Interrupt Vector
    `@INTERRUPT_11`
    reti

    org 30h                 ;Analog Column 2 Interrupt Vector
    `@INTERRUPT_12`
    reti

    org 34h                 ;Analog Column 3 Interrupt Vector
    `@INTERRUPT_13`
    reti

    org 38h                 ;GPIO Interrupt Vector
    `@INTERRUPT_14`
    reti

    org 3Ch                 ;Sleep Timer Interrupt Vector
    `@INTERRUPT_15`
    reti

;-----------------------------------------------------------------------------
;  Start of Execution
;  CPU is operating at 3 MHz, change to 12 MHz
;  IO Bank is Bank0
;-----------------------------------------------------------------------------
    org 40h
__Start:
    mov [bSSC_KEY1] ,0      ;Lockout Flash and Supervisiory operations
    mov [bSSC_KEYSP],0      ;(especially after a Software Reset Supervisory op)

    mov A,__bss_end         ;Set top of stack to end of used RAM
IF (COMM_RX_PRESENT)
    cmp A,40h
    jnc .SetStack           ; Stack must start at or above 40h
    mov A,40h
ENDIF ;(COMM_RX_PRESENT)

.SetStack:
    swap SP,A

    ;-------------------------------------------------------------------------
    ; Set clock and BandGap trim if the operating voltage is 3.3V. On power
    ; up, 5V is loaded, so this is only needed for 3.3V operation.
    ;-------------------------------------------------------------------------

IF (SUPPLY_VOLTAGE)                ; 1 means 5.0V
ELSE                               ; 0 means 3.3V
    mov  [bSSC_TABLE_TableId], 1   ; Point to the Trim table
    SSC_Action TABLE_READ          ; Perform a table read supervisor call
    M8C_SetBank1
    mov  A, [OSCILLATOR_TRIM_3V]   
    mov  reg[IMO_TR], A            ; Load the 3V trim oscillator setting
    mov  A, [VOLTAGE_TRIM_3V]
    mov  reg[BDG_TR], A            ; Load the bandgap trim setting for 3V
    M8C_SetBank0
ENDIF ;(SUPPLY_VOLTAGE)

    ;-------------------------------------------------------------------------
    ; If the user has requested the Crystal oscillator then turn it on and
    ; wait for it to stabilize and the system to switch over to it.  The wait
    ; will be one sleep timer period, approximately 1 second.
    ;-------------------------------------------------------------------------

IF (SELECT_32K & WAIT_FOR_32K)

    ; This will be used for XTAL and PLL startup, and is cancelled later on.
    mov reg[INT_MSK0], INT_MSK0_Sleep   ; Only turn on Sleep interrupt
    mov reg[INT_MSK1], 0           ; Some could be on if s/w reset took place

    M8C_SetBank1

    mov reg[PRT1DM0],00h           ; P1[0] & P1[1] Drive Mode to High Z because
    mov reg[PRT1DM1],03h           ; LoadConfigInit not run yet.
IF (PLL_MODE)
    mov reg[ECO_TR],0Fh            ; adjust ECO bias if in PLL lock mode
ENDIF ;(PLL_MODE)
    M8C_SetBank0
    M8C_ClearWDTAndSleep           ; Reset the sleep timer

    M8C_SetBank1
    mov reg[OSC_CR0], (OSC_CR0_Sleep_1Hz | SELECT_32K_JUST | OSC_CR0_CPU_12MHz) 
    M8C_SetBank0

    mov reg[INT_VC],0              ; Clear all pending interrupts
.WaitFor1s:
    mov A, reg[INT_VC]             ; read Interrupt Vector
    jz .WaitFor1s                  ; TimeOut occurs on Sleep Timer 1s

    M8C_SetBank1
    mov reg[ILO_TR], 40h           ; turn off the ILO, 32K is now from the ECO
    M8C_SetBank0

ELSE ;!(SELECT_32K & WAIT_FOR_32K)
    mov reg[INT_MSK0], 0           ; Turn off all interrupts
    mov reg[INT_MSK1], 0           ; some could be on if s/w reset took place
    M8C_SetBank1
    mov reg[OSC_CR0], (OSC_CR0_Sleep_1Hz | OSC_CR0_CPU_12MHz)
    M8C_SetBank0
    M8C_ClearWDTAndSleep           ; Reset the sleep timer

ENDIF ;(SELECT_32K & WAIT_FOR_32K)

    ;-------------------------------------------------------------------------
    ; Crystal is now fully operational. 
    ;-------------------------------------------------------------------------

IF (PLL_MODE)
IF (SELECT_32K)
    M8C_SetBank1
    mov reg[OSC_CR0], (PLL_MODE_JUST | OSC_CR0_Sleep_64Hz | SELECT_32K_JUST | OSC_CR0_CPU_12MHz)
    M8C_SetBank0

    M8C_ClearWDTAndSleep        ; Reset the sleep timer

    mov reg[INT_VC],0           ; Clear all pending interrupts
.WaitFor16ms:
    mov A, reg[INT_VC]          ; read Interrupt Vector
    jz .WaitFor16ms             ; TimeOut occurs on Sleep Timer 16ms

ELSE ;!(SELECT_32K)
    ERROR_PSoC Using the PLL without the Crystal is invalid.
ENDIF ;(SELECT_32K)
ENDIF ;(PLL_MODE)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -