📄 psmon.asm
字号:
;********************************************************************
;
; Author : ADI - Apps www.analog.com/MicroConverter
;
; Date : May 2002
;
; File : PSMon.asm
;
; Hardware : ADuC831
;
; 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.63V) 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.
;
;********************************************************************
$MOD831 ; Use 8052&ADuC831 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.
CLR LED
RETI ; return only when "all's well"
;====================================================================
; MAIN PROGRAM
ORG 0060h ; start program above interrupts
MAIN:
MOV PSMCON, #0C1H ; enable PSM with
; AVdd 4.63V threshold
; DVdd 4.63V threshold
MOV IEIP2, #22H ; enable PSM interrupt
; high priority for PSM interrupt
SETB EA ; enable interrupts
FLASH: ; Main Routine would go here
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 delay)
RET
;____________________________________________________________________
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -