📄 prog20.asm
字号:
; PROG20 - Do a Debounce on a button and Toggle an LED
;
; This Application polls the button and toggles the LED
; State when the button is pressed (and has been "Debounced").
;
; The button is assumed to be debounced if it does not change
; state for 20 msecs.
;
; Myke Predko
; 98.02.20
;
; Hardware Notes:
; 80C520 Running at 1 MHz
; P1.0 is the LED (to light, it is pulled down)
; P1.1 is connected to a Momentary ON Switch that Pulls down the Line.
; Variable Declarations
; Just "A" and "B" are used for this program.
; Mainline
org 0 ; Execution Starts Here
Loop: ; Loop Here Forever
PressWait: ; Wait for the Button to be Pressed
jb P1.1,PressWait
mov A,#191 ; Setup 20 msec Delay
mov B,#10
PressDebounce: ; Now, See if the Button is Held down
jb P1.1,PressWait ; 20 msec - If Released, Start Delay Over
djnz ACC,PressDebounce
djnz B,PressDebounce
; #### - Button Press is Debounced
cpl P1.0 ; Toggle the LED State
ReleaseWait: ; Now, Wait for the Button to be Released
jnb P1.1,ReleaseWait
sjmp Loop
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -