genericreset.asm

来自「Alarm clock with PIC microcontroller」· 汇编 代码 · 共 97 行

ASM
97
字号
;==============================================================================
; Reset Vector
;------------------------------------------------------------------------------

; Notes
;
; This module provides a generic handler for resets. It checks the state of the
; STATUS register and special function registers (if available) to determine
; the reason for the reset and executes an appropriate handler (definable in
; the user application).
;
; Some portions of the code are adjusted if the device does not have a paged
; code area to produce less instructions.

;==============================================================================
; Revision History:
;
; 2004-12-27 AJ Initial version
;------------------------------------------------------------------------------

                include ../pic.inc

                errorlevel -302
                errorlevel -312

                global  Reset

                extern  PowerOnReset
                extern  WatchDogReset
                extern  MCLRReset

                if      HAS_BO_DETECT
                extern  BrownOutReset
                endif

;==============================================================================

                code

; Test /TO bit to see if a timeout generated the reset

Reset:
                btfss   STATUS,NOT_TO
                if      HAS_BANKED_ROM
                goto    Timeout
                else
                goto    WatchDogReset
                endif

; If /TO = 1 then examine /PD to differentiate between POR (or BOR) and MCLR.

                btfss   STATUS,NOT_PD
                if      HAS_BANKED_ROM
                goto    MCLR
                else
                goto    MCLRReset
                endif

; If /TO = 1 and /PD = 1 then POR or BOR has occurred (if the PIC supports its
; detection).

                if      HAS_BO_DETECT
                banksel PCON
                btfsc   PCON,NOT_POR
                 if      HAS_BANKED_ROM
                goto    BrownOut
                lgoto   PowerOnReset
BrownOut:
                lgoto   BrownOutReset
                 else
                goto    BrownOutReset
                goto    PowerOnReset
                 endif
                else
                lgoto   PowerOnReset
                endif

; If /TO = 1 and /PD = 0 the the MCLR pin has been used to reset the device.

MCLR:
                if      HAS_BANKED_ROM
                lgoto   MCLRReset
                else
                goto    MCLRReset
                endif

; If /TO = 0 then the watch dog timer is enabled and has triggered an reset.

Timeout:
                if      HAS_BANKED_ROM
                lgoto   WatchDogReset
                else
                goto    WatchDogReset
                endif

                end

⌨️ 快捷键说明

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