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

📄 psmons.asm

📁 aduc814的汇编程序例子
💻 ASM
字号:
;********************************************************************
;
; Author        : ADI - Apps            www.analog.com/MicroConverter
;
; Date          : 12 February 2001
;
; File          : PSMonS.asm
;
; Hardware      : ADuC814
;
; 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.
;
;********************************************************************
$MOD814

LED     EQU     P3.3            ; P3.3 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)

        CLR     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 0060h                       ; start program above interrupts

MAIN:

        MOV     PSMCON, #041H   ; enable PSM with 
				;  Vdd 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
                                                        ; 100ms DELAY
DELAY:					; Delays by 100ms * A
					; 100mSec based on 2.097152MHZ 
					; Core Clock 
					; i.e. default ADuC814 Clock

		
    	        MOV    	R2,#022h	; Set up delay loop0
 DLY1:		MOV	R3,#0FFh	; Set up delay loop1
		DJNZ	R3,$		; Dec R3 & Jump here until R3 is 0
		DJNZ	R2,DLY1         ; Dec R2 & Jump DLY1 until R2 is 0
		RET			; Return from subroutine

;____________________________________________________________________

END

⌨️ 快捷键说明

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