2
; $Id: test_toie0.asm,v 1.2 2003/11/29 09:43:14 troth Exp $
4
;;; Test the Timer/Counter 0 overflow interrupt functionality.
5
;;; This test will stop the counter by setting the clock select
6
;;; value in TCCR0 to 0 (stop).
10
.equ zero, 17 ; r17 preset with 0x00
11
.equ ones, 18 ; r18 preset with 0xff
12
.equ disp, 19 ; r19 is output display
14
;;; Interrupt Jump Table
22
rjmp TIMER_OVF ; timer0 ovf
30
;; Toggle the leds on Port B so we know that the interrupt
31
;; occured and was handled.
32
out PORTB, disp ; set the leds
33
dec disp ; decrement the display counter
35
;; if disp has counted down to 0, stop the counter via TCCR,
36
;; but leave the interrupt enabled
37
brne OVF_RETURN ; skip to reti if disp is not zero
39
out TCCR0, r20 ; set clock select to 0x00 (stop)
42
reti ; return from interrupt
45
;; init stack pointer to 0x025f (the last byte of int sram)
46
ldi r16, lo8(RAMEND); low byte of end of int sram
48
ldi r16, hi8(RAMEND); high byte of end of int sram
51
;; preload zero and ones
56
;; init portb for output
60
;; Set the clock select for Timer0 to CK/256
61
ldi r20, 0x04 ; CS[2,1,0] = [1,0,0]
62
out TCCR0, r20 ; write to Timer/Counter Control Register 0
64
;; Enable the Timer0 Overflow interrupt
66
out TIMSK, r20 ; set toie0 bit of timsk I/O register
67
sei ; set global interrupt enable (in sreg)
70
;; Loop until r20 is zero