Krolyxon
Commit a921fe1

Branches

Tags

Refs →

bench51examplestimer_irq.asm

28 lines · 698 B · x86_64 Assembly

1; Timer 0 interrupt: mode 1 (16-bit) overflow every 1000 cycles toggles P1.0
2; and counts ticks in R7. The main loop just idles.
3
4RELOAD EQU 65536 - 1000
5
6 ORG 0000h
7 LJMP main
8
9 ORG 000Bh ; timer 0 overflow vector
10 LJMP t0_isr
11
12 ORG 0030h
13main: MOV SP,#5Fh
14 MOV TMOD,#01h ; T0: mode 1, timer
15 MOV TH0,#HIGH RELOAD
16 MOV TL0,#LOW RELOAD
17 SETB ET0 ; enable timer 0 interrupt
18 SETB EA ; global interrupt enable
19 SETB TR0 ; start timer 0
20idle: SJMP idle
21
22t0_isr: MOV TH0,#HIGH RELOAD
23 MOV TL0,#LOW RELOAD
24 CPL P1.0
25 INC R7
26 RETI
27
28 END