

ORG 00H
LJMP MAIN
ORG 002BH
LJMP T2ISR

MAIN:

MOV P1,#0FFH
MOV T2MOD,#02H                ;timer 2 initialisation    
MOV T2CON,#04H
MOV IE,#0A0H                  ;interrupt enable
MOV RCAP2L,#-1000
MOV RCAP2H,#-1000             ;auto reload values

SETB TF2                      ;forcing timer2 interrupt (which 
SJMP $                                   is not working)

T2ISR:

CLR TR2                        ;timer2 stoped and flag cleared
CLR TF2

CPL P1.5       

SETB TR2                       ;timer2 started again
RETI
END
