Last active
November 23, 2016 09:11
-
-
Save clive819/1bb928e5c44eaabdcea2e274c7e78ac9 to your computer and use it in GitHub Desktop.
Revisions
-
clive819 revised this gist
Nov 23, 2016 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,6 @@ toCount EQU 10 LJMP main org 000bh LJMP TO_ISR main: MOV IE, #10000010b MOV TMOD, #00000001b @@ -21,6 +20,7 @@ main: MOV decBuf, #90 MOV a, #0 ACALL setdigits MOV A, #0ffh MOV P2, a MOV P3, a MOV keyBuf1, #0ffh @@ -35,7 +35,6 @@ reset: MOV port4, A ACALL covled ACALL getkeycode ACALL delay inc r0 RL A @@ -140,7 +139,7 @@ TO_ISR: SETB TR0 DEC toBuf MOV A, toBuf JNZ exit1 MOV toBuf, #toCount ACALL display2decimal exit1: -
clive819 created this gist
Nov 23, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,168 @@ port4 EQU 0E8h shift7LED EQU 0FEh dispBuf EQU 40h keyBuf1 EQU 44h keyBuf2 EQU 45h keyCode EQU 46h decBuf EQU 50h toBuf EQU 49h toCount EQU 10 org 0000h LJMP main org 000bh LJMP TO_ISR main: MOV IE, #10000010b MOV TMOD, #00000001b SETB TR0 MOV toBuf, #toCount MOV decBuf, #90 MOV a, #0 ACALL setdigits MOV P2, a MOV P3, a MOV keyBuf1, #0ffh MOV keyBuf2, #0ffh MOV keyCode, #0 MOV dptr, #led_table reset: MOV r0, #dispBuf MOV a, #shift7LED loop: MOV port4, A ACALL covled ACALL getkeycode ACALL displaykeycode ACALL delay inc r0 RL A jb ACC.4, loop Sjmp reset Getkeycode: PUSH 0E0h MOV a, p2 MOV keyBuf1, a MOV a, p3 MOV keyBuf2, a MOV a, keyBuf2 cjne a, #0ffh, nextcode0 MOV a, keyBuf1 MOV r2, #0 nextcode1: jnb 0e0h, gotkeycode inc r2 rr a cjne r2, #8, nextcode1 sjmp exitgetkeycode nextcode0: MOV a, keyBuf2 MOV r2, #8 nextcode2: jnb 0e0h, gotkeycode inc r2 rr a cjne r2, #16, nextcode2 sjmp exitgetkeycode gotkeycode: MOV keyCode, r2 exitgetkeycode: POP 0E0h ret Displaykeycode: PUSH 0E0h MOV a, keyCode MOV dispBuf, a MOV dispBuf+1, a MOV dispBuf+2, a MOV dispBuf+3, a POP 0E0h ret Delay: MOV r4, #1 delay0: MOV r5, #2 delay1: MOV r6, #100 delay2: MOV r7, #100 delay3: djnz r7, delay3 djnz r6, delay2 djnz r5, delay1 djnz r4, delay0 ret Covled: PUSH 0E0h MOV a, @R0 ANL a, #0fh MOVC a, @a+dptr MOV p0, a POP 0E0h ret setdigits: PUSH 0E0h MOV 40h,0e0h MOV 41h,0e0h MOV 42h,0e0h MOV 43h,0e0h POP 0e0h RET display2decimal: PUSH 0E0h MOV A, decBuf MOV B, #10 DIV AB MOV dispBuf+2, A MOV dispBuf+3, B INC decBuf MOV A, decBuf CJNE A, #100, exit MOV decBuf, #0 exit: POP 0E0h RET TO_ISR: PUSH 0E0h CLR TR0 MOV TH0, #60 MOV TL0, #176 SETB TR0 DEC toBuf MOV A, toBuf JZ exit1 MOV toBuf, #toCount ACALL display2decimal exit1: POP 0E0h RETI Led_table: DB 0c0h DB 0F9h DB 0A4h DB 0B0h DB 99h DB 92h DB 82h DB 0D8h DB 80h DB 90h DB 88h DB 83h DB 0C6h DB 0A1h DB 86h DB 8Eh end