Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Date: 20141023
- ; Project: Timer
- ; Group: Six(6)
- ; Maker: Yan
- ; E-Mail: [email protected]
- LED EQU P1
- ORG 0000h
- REFRESH:
- MOV TMOD, #00010001b ; Set Timer to work in Mode 1 (16-bit Timer)
- MOV A, #11111111b
- ; Make a 8-Bit Up-Counter
- LOOP:
- DEC A
- MOV LED, A
- CALL DELAY
- MOV B, #5
- CJNE A, #11100000b, LOOP ; Compare two numbers. If it's not equal, the program will goto the specified function.
- ; Like this. If (A != B),the program will goto the function [LOOP].
- SHOW:
- MOV LED, #081h
- CALL DELAY
- MOV LED, #042h
- CALL DELAY
- MOV LED, #024h
- CALL DELAY
- MOV LED, #018h
- CALL DELAY
- MOV LED, #081h
- CALL DELAY
- MOV LED, #042h
- CALL DELAY
- MOV LED, #024h
- CALL DELAY
- MOV LED, #018h
- CALL DELAY
- DJNZ B, SHOW
- CALL REFRESH
- ;----------------Totle can delay about [130ms]----------------
- DELAY:
- MOV R4, #2 ;Run 2 time
- TIMER_0:
- ; Set Timer count bit = [0000 0000] = 65535 * 1us = 65535 = 65ms
- MOV TL0, #000h
- MOV TH0, #000h
- ;Turn on Timer
- SETB TR0
- ; Wait for Timer stop(Timer interrupt Flag)
- WAIT_0:
- JBC TF0, OVER
- JMP WAIT_0
- OVER:
- CLR TF0 ; Clear Timer interrupt Flag
- DJNZ R4, TIMER_0
- RET
- ;-------------------------------------------------------------
- END
Advertisement
Add Comment
Please, Sign In to add comment