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

📄 psmon.asm

📁 aduc812的汇编例子
💻 ASM
字号:
;********************************************************************
;
; Author        : ADI - Apps            www.analog.com/MicroConverter
;
; Date          : 28 May 1999
;
; File          : PSMon.asm
;
; Hardware      : ADuC812
;
; Description   : Demonstrates use of on-chip power supply monitor.
;                 In normal operation, this code flashes the LED at
;                 approximately 5Hz.  when Vdd drops below the user
;                 specified trip-point (here 4.37V) the PSM interrupt
;                 is executed.  once inside this interrupt service
;                 routine, this code waits until the PSM interrupt
;                 bit becomes zero again, indicating that the power
;                 supply is again above the trip point and has been
;                 there for at least 256ms.  at this point, a RETI
;                 instruction is executed, and normal code execution
;                 is resumed, indicated by the flashing LED.
;
;********************************************************************

$MOD812                         ; Use 8052&ADuC812 predefined symbols

LED     EQU     P3.4            ; P3.4 drives red LED on eval board

;____________________________________________________________________
                                                  ; BEGINNING OF CODE
CSEG

ORG 0000h

        JMP     MAIN            ; jump to main program
;____________________________________________________________________
                                             ; INTERRUPT VECTOR SPACE
ORG 0043h ;  (PSM ISR)

        SETB     LED             ; turn off the LED to indicate fault

; most often, a routine would here be called to store critical values
; in user Flash/EE space and wait in a "safe" state of code execution
; until the PSM interrupt bit becomes zero indicating that adequate
; power supply voltage has returned.

CHECK:  MOV     A,PSMCON        ; PSMCON.5 is the PSM interrupt bit..
        JB      ACC.5,CHECK     ; ..it is cleared only when Vdd has
                                ; remained above the trip point for
                                ; 256ms or more.
        RETI                    ; return only when "all's well"

;====================================================================
                                                       ; MAIN PROGRAM
ORG 004Bh

MAIN:

        MOV     PSMCON,#005h    ; enable PSM with 4.37V threshold
        SETB    EA              ; enable interrupts
        MOV     IE2,#002h       ; enable PSM interrupt

FLASH:  CPL     LED             ; blink LED indicating norm operation
        CALL    DELAY           ; delay 100ms
        JMP     FLASH           ; loop

;____________________________________________________________________
                                                         ; SUBROUTINE

DELAY:                          ; delay 100ms

        MOV     R7,#200         ; 200 * 500us = 100ms
DLY1:   MOV     R6,#229         ; 229 * 2.17us = 500us
        DJNZ    R6,$            ; sit here for 500us
        DJNZ    R7,DLY1         ; repeat 200 times (100ms total)
        RET

;____________________________________________________________________

END

⌨️ 快捷键说明

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