单片机源程序如下:
- ORG 0000H
- LJMP MAIN
- ORG 000BH
- LJMP TIM0
- ORG 0030H
- MAIN: MOV TMOD,#01H
- MOV IE,#82H
- MOV 30H,#00H
- NEXT: MOV A,30H
- MOV DPTR,#TABLE
- MOVC A,@A+DPTR
- MOV R2,A
- JZ END0
- ANL A,#0FH
- MOV R5,A
- MOV A,R2
- SWAP A
- ANL A,#0FH
- JNZ SING
- CLR TR0
- LJMP D1
- SING: DEC A
- MOV 22H,A
- RL A
- MOV DPTR,#TABLE1
- MOVC A,@A+DPTR
- MOV TH0,A
- MOV 21H,A
- MOV A,22H
- RL A
- INC A
- MOVC A,@A+DPTR
- MOV TL0,A
- MOV 20H,A
- SETB TR0
- D1: LCALL DELAY
- INC 30H
- LJMP NEXT
- END0: CLR TR0
- LJMP MAIN
- TIM0: PUSH ACC
- PUSH PSW
- MOV TL0,20H
- MOV TH0,21H
- CPL P1.0
- POP PSW
- POP ACC
- RETI
- DELAY: MOV R7,#02H
- D2: MOV R4,#187
- D3: MOV R3,#248
- DJNZ R3,$
- DJNZ R4,D3
- DJNZ R7,D2
- DJNZ R5,DELAY
- RET
- TABLE1: DW 64260,64400,64521,64580
- DW 64684,64777,64820,64898
- DW 64968,65030,65058,65110
- DW 65157,65178,65217
- TABLE: DB 82H,01H,81H,94H,84H
- DB 0B4H,0A4H,04H
- DB 82H,01H,81H,94H,84H
- DB 0C4H,0B4H,04H
-
- DB 82H,01H,81H,0F4H,0D4H
- DB 0B4H,0A4H,04H
- DB 0E2H,01H,0E1H,0D4H,0B4H
- DB 0C4H,0B4H,04H
- DB 82H,01H,81H,94H,84H
- DB 0B4H,0A4H,04H
- DB 82H,01H,81H,94H,84H
- DB 0C4H,0B4H,04H
- DB 82H,01H,81H,0F4H,0D4H
- DB 0B4H,0A4H,94H
- DB 0E2H,01H,0E1H,0D4H,0B4H
- DB 0C4H,0B4H,04H
- DB 00H
- END
复制代码
|