?? keyboard.a51
字號:
$INCLUDE (reg_c51.INC)
;/*_____ D E C L A R A T I O N ___________________________________________*/
keypressed DATA 10H; /* key pressed value */
key_flag BIT 20H; /* software flag */
org 000h
ljmp begin
org 3Bh
ljmp keyboard_it
;/**
; * FUNCTION_PURPOSE:this function setup keyboard.
; * A key set idle mode and an other set the power-down mode
; * In this two mode the microcontoleur wake up at keyboard event
; * FUNCTION_INPUTS:void
; * FUNCTION_OUTPUTS:void
; */
org 0100h
begin:
SETB EA; /* enable interrupts */
;/* init keyboard */
MOV KBE,#0FFh; /*Enable all P1 I/O as keyboard IO */
MOV KBF,#00; /* Clear all keyboard flags */
ORL IEN1,#01h; /* Enable keyboard interupt */
loop:
JNB key_flag,end_if_key_flag /* keyboard occur */
MOV R7, keypressed;
CJNE R7,#10h,end_if_key0x10; /*enter Idle mode */
; /* Entering Idle Mode */
ORL PCON,#01h;
; /* Wake up by keypressed value */
end_if_key0x10:
CJNE R7,#20h,end_if_key0x20; /* enter powerdown mode */
; /* Entering PowerDown Mode */
ORL PCON,#02h;
; /* Wake up by keypressed value */
end_if_key0x20:
CLR key_flag; /* reset softaware flag */
end_if_key_flag:
JMP loop
;/**
;* FUNCTION_PURPOSE:keyboard_interrupt. Save pressed key
;* FUNCTION_INPUTS:void
;* FUNCTION_OUTPUTS:void
;*/
keyboard_it:
MOV keypressed,KBF; /* save pressed key */
SETB key_flag; /* set the software flag */
MOV KBF,#00h; /* clear keyboard flags */
RETI
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -