Saturday, April 30, 2016

8051 Program – 1sec delay timer

; 1 second delay timer
ORG 0H
SJMP 30H

ORG 0BH ; timer 0 isr
SJMP ISR

ORG 30H
MOV A,#00
MOV R0,#0
MOV R1,#0
MOV TMOD,#02H ;00000010-Run timer0 in mode 2
MOV TH0,#118 ;Set up timer 0 to overflow in 0.05msec
MOV IE,#82H ;%10000010 – Enable timer0 interrupt
SETB TCON.4 ;Start the timer0HERE:SJMP HERE
HERE: SJMP HERE
ISR:CLR TCON.4 ;Disable timer0
INC R1 ;r1*r2 = 100*200 = 20000 * 0.05msec = 1sec
CJNE R1,#100,SKIP
MOV R1,#00
INC R0
CJNE R0,#200,SKIP
MOV R0,#00H
INC A
SKIP: SETB TCON.4 ;Enable Timer
RETI ;Return from interrupt subroutine
END



Related topics:
8051 Program - find out of range data   |   8051 Program - ones and twos complement   |   8051 Program - check for NULL   |   8051 Program - check nth bit of a byte   |   8051 Program - 1ms delay   |   8051 Program - memory subroutines   |   8051 Program - math subroutines   |   8051 Program - conversion subroutines

List of topics: 8051

No comments:

Post a Comment