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

📄 boot.asm

📁 bootload 汇编语言
💻 ASM
📖 第 1 页 / 共 4 页
字号:
;=====================================
; MEGASQUIRT BOOTLOADER VERSION - Dec 2001
;  Config register mod for raising LVI trip point - May 2003 
;  Version for code revisions 2.86 or higher
;
; Mods by Bruce Bowling
;
; Fixed "ldx" to "lda" in "resetboot5:
;
;=====================================

.header 'MC68HC908GP32 User Bootloader'
.base 10t
.pagewidth 130
.pagelength 90
;********************************************************************************************
;*                                                                                          *
;*  Bootloader - MC68HC908GP32                                                              *
;*                                                          Copyright (c) Motorola, 2001    *
;*                                                                                          *
;********************************************************************************************
;*                                                                                          *
;*  This file provides the low level assembly bootloader routine.                           *
;*  This program has been specially tailored towards the MC68HC908GP32.                     *
;*                                                                                          *
;********************************************************************************************
;*                                                                                          *
;*  File name:          boot.asm                        Current Release Level:      1.1     *
;*  Last Edit Date:     07-Jun-01                       Classification:             ES      *
;*                                                                                          *
;*  Include Files:      gp32.equ            : MC68HC908GP32 MCU definitions                 *
;*                                                                                          *
;*  Assembler:          P&E's CASM08Z                   Version:    3.16                    *
;*                                                                                          *
;*  Target:             MC68HC908GP32                                                       *
;*                                                                                          *
;*  Documentation:      MC68HC908GP32/H  Rev 3                                              *
;*                      Motorola Microcontroller Technical Data                             *
;*                                                                                          *
;********************************************************************************************
;*                                                                                          *
;*  Author:             DHJ Klotz                                                           *
;*  First Release:      26-Feb-00                                                           *
;*                                                                                          *
;*  Update History:                                                                         *
;*                                                                                          *
;*  Rev     Date       Author  Description of Change                                        *
;*  ------  ---------  ------  -----------------------------------------------------------  *
;*  ES 1.0  26-Feb-00  DHJK    Initial release for HC908 Seminar 2000.                      *
;*  ES 1.1  07-Jun-01  DHJK    Improved functionality for Application Note.                 *
;*                                                                                          *
;********************************************************************************************
;*                                                                                          *
;*  Notes:                                                                                  *
;*    - In order to minimize overall program size, subroutines are position within the      *
;*      core bootloader routine.  Although this can make the program somewhat difficult     *
;*      to read and follow, it permits the use of relative branch opcodes.  Most of         *
;*      these subroutines can be called from an external application program.               *
;*                                                                                          *
;********************************************************************************************
;*                                                                                          *
;*    Motorola reserves the right to make changes without further notice to any product     *
;*    herein to improve reliability, function, or design.  Motorola does not assume any     *
;*    liability arising out of the application or use of any product, circuit, or software  *
;*    described herein; neither does it convey any license under its patent rights nor the  *
;*    rights of others.  Motorola products are not designed, intended, or authorized for    *
;*    use as components in systems intended for surgical implant into the body, or other    *
;*    applications intended to support life, or for any other application in which the      *
;*    failure of the Motorola product could create a situation where personal injury or     *
;*    death may occur.  Should Buyer purchase or use Motorola products for any such         *
;*    intended or unauthorized application, Buyer shall indemnify and hold Motorola and     *
;*    its officers, employees, subsidiaries, affiliates, and distributors harmless against  *
;*    all claims, costs, damages, and expenses, and reasonable attorney fees arising out    *
;*    of, directly or indirectly, any claim of personal injury or death associated with     *
;*    such unintended or unauthorized use, even if such claim alleges that Motorola was     *
;*    negligent regarding the design or manufacture of the part.                            *
;*                                                                                          *
;*    Motorola and the Motorola logo are registered trademarks of Motorola Ltd.             *
;*                                                                                          *
;********************************************************************************************

;*  Microcontroller Peripheral Equates  *****************************************************
;*

; uncomment out if standalone
        nolist

;        include "gp32.equ"
        list


;*  Flash Memory Specifics  =================================================================
;*
boot_start:     equ     $FB00               ; starting address of protected Bootloader
flash_protect:  equ     {boot_start>7&$FF}  ; Flash Block Protect Register value
flash_page:     equ     128                 ; Flash Erase Page size
flash_row:      equ     64                  ; Flash Program Row size
flash_erased:   equ     $FF                 ; Flash erased state


;*  RAM Utilization  ========================================================================
;*
        org     ram_start                   ; begining of RAM

count:          ds      1                   ; 0040:     => data counter
temp_sp:        ds      2                   ; 0041:0042 => temporary Stack Pointer storage
flash_first:    ds      2                   ; 0043:0044 => first Flash reprogram address
flash_last:     ds      2                   ; 0045:0046 => last Flash reprogram address + 1

ram_exec:       equ     $01ED               ; start of executable RAM space


;*  Bootloader Customization Parameters  ====================================================
;*
user_scbr:      equ     boot_start-61       ; FAC3      => SCBR register
init_scbr:      equ     $12                 ;   default set SCI for 9600 kbaud

user_config1:   equ     boot_start-60       ; FAC4      => CONFIG1 register
init_config1:   equ     %00000001           ;   default CONFIG1

user_config2:   equ     boot_start-59       ; FAC5      => CONFIG2 register
init_config2:   equ     %00000001           ;   default CONFIG2

user_first:     equ     boot_start-58       ; FAC6:FAC7 => 1st application address
init_first:     equ     rom_start           ;   default first Flash address

user_last:      equ     boot_start-56       ; FAC8:FAC9 => last application address
init_last:      equ     boot_start          ;   default last Flash address


;*  Application Program Jump Vector Table  ==================================================
;*
                                            ; FACA      => "JMP ext" instruction (opcode $CC)
user_timebase:  equ     boot_start-54       ; FACB:FACC => user Timebase jump vector

                                            ; FACD      => "JMP ext" instruction (opcode $CC)
user_ADC:       equ     boot_start-51       ; FACE:FACF => user ADC jump vector

                                            ; FAD0      => "JMP ext" instruction (opcode $CC)
user_keyboard:  equ     boot_start-48       ; FAD1:FAD2 => user Keyboard jump vector

                                            ; FAD3      => "JMP ext" instruction (opcode $CC)
user_SCItx:     equ     boot_start-45       ; FAD4:FAD5 => user SCI transmit jump vector

                                            ; FAD6      => "JMP ext" instruction (opcode $CC)
user_SCIrx:     equ     boot_start-42       ; FAD7:FAD8 => user SCI receive jump vector

                                            ; FAD9      => "JMP ext" instruction (opcode $CC)
user_SCIerr:    equ     boot_start-39       ; FADA:FADB => user SCI error jump vector

                                            ; FADC      => "JMP ext" instruction (opcode $CC)
user_SPItx:     equ     boot_start-36       ; FADD:FADE => user SPI transmit jump vector

                                            ; FADF      => "JMP ext" instruction (opcode $CC)
user_SPIrx:     equ     boot_start-33       ; FAE0:FAE1 => user SPI receive jump vector

                                            ; FAE2      => "JMP ext" instruction (opcode $CC)
user_Tim2Ov:    equ     boot_start-30       ; FAE3:FAE4 => user Timer 2 overflow jump vector

                                            ; FAE5      => "JMP ext" instruction (opcode $CC)
user_Tim2Ch1:   equ     boot_start-27       ; FAE6:FAE7 => user Timer 2 channel 1 jump vector

                                            ; FAE8      => "JMP ext" instruction (opcode $CC)
user_Tim2Ch0:   equ     boot_start-24       ; FAE9:FAEA => user Timer 2 channel 0 jump vector

                                            ; FAEB      => "JMP ext" instruction (opcode $CC)
user_Tim1Ov:    equ     boot_start-21       ; FAEC:FAED => user Timer 1 oveflow jump vector

                                            ; FAEE      => "JMP ext" instruction (opcode $CC)
user_Tim1Ch1:   equ     boot_start-18       ; FAEF:FAF0 => user Timer 1 channel 1 jump vector

                                            ; FAF1      => "JMP ext" instruction (opcode $CC)
user_Tim1Ch0:   equ     boot_start-15       ; FAF2:FAF3 => user Timer 1 channel 0 jump vector

                                            ; FAF4      => "JMP ext" instruction (opcode $CC)
user_PLL:       equ     boot_start-12       ; FAF5:FAF6 => user PLL jump vector

                                            ; FAF7      => "JMP ext" instruction (opcode $CC)
user_IRQ:       equ     boot_start-9        ; FAF8:FAF9 => user IRQ jump vector

                                            ; FAFA      => "JMP ext" instruction (opcode $CC)
user_SWI:       equ     boot_start-6        ; FAFB:FAFC => user SWI jump vector

                                            ; FAFD      => "JMP ext" instruction (opcode $CC)
user_reset:     equ     boot_start-3        ; FAFE:FAFF => user Reset interrupt jump vector


;*  Bootloader Program  *********************************************************************
;*

init_stack:     equ     ram_exec-1          ; initialize stack pointer to before RAM routine
;
init_scc1:      equ     %01000000           ; enable SCI, 8-bits, no parity, 1 stop
init_scc2:      equ     %00001100           ; no interupts, receiver and transmitter enabled

        org     boot_start                  ; beginning of code


;*  CGM Parameter Tables  ===================================================================
;*
;*  The following CGM parameter tables are placed here so that they are easy to access via
;*  external application programs.
;*
;*  7.3728 MHz bus frequency parameters (located at address "boot_start").
;*
bus7372800:
        db      $02                         ; P & E
        db      $C0                         ; L
        db      $03                         ; N msb
        db      $84                         ; N lsb

;*  8.003584 MHz bus frequency parameters (located at address "boot_start+4").
;*
bus8003584:
        db      $02                         ; P & E
        db      $D0                         ; L
        db      $03                         ; N msb
        db      $D1                         ; N lsb


;*  Power-on Reset  =========================================================================
;* MODIFIED FOR MEGASQUIRT - Initialization code here
;*

BootReset:
	clra
	sta	copctl
	mov	#%00000001,config2
;	mov	#%00000001,config1
	mov	#%00001001,config1           ; Enable 5 volt trip for LVI
	ldhx	#ram_last+1
	txs

        ldhx    #bus7372800                 ; point to 7.3728 MHz parameters
        bsr     PLLset                      ; change bus speed

	lda	 #%00000000
	sta	 ddrb			    ; ADC Channels - inputs

	lda	#%01110000		    ; Set up ADC for divide by 8 and internal clock
	sta	adclk
	lda	#%00000100		    ; No interrupt, channel AD4 selected
	sta	adscr
	brclr	coco,adscr,*		    ; wait until conversion complete

	lda	adr
	cmp	#$05			    ; Check for low voltage on divider
	blo	BootReset1	 	    ; enter bootloader if low voltage

;
;   Test application reset vector.
;
        lda     user_reset+1                ; get the MSB of the user reset vector
        cmp     #flash_erased               ; check if it's erased
        beq     BootReset1                  ; enter bootloader if erased
        bra     user_reset                  ; else, jump to user reset jump vector


;*  External CGM PLL Bus Frequency Change Subroutine  =======================================
;*
;*  This subroutine will program the CGM PLL to change the bus frequency in accordance with
;*  the data being pointed to by X:A (which is a common implementation for pointer parameter
;*  passing used by HC08 C compilers).
;*
;*  C function prototype:
;*
;*      void CGMChange (char parameters*);
;*
;*  Calling convention:
;*
;*      ldx     #{parameters>8}             ; get CGM parameter table address msb
;*      lda     #{parameters&$FF}           ; get CGM parameter table address lsb
;*      jsr     CGMChange                   ; go change the bus speed
;*
;*  Returns:    nothing
;*

⌨️ 快捷键说明

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