~ubuntu-branches/ubuntu/dapper/simulavr/dapper

« back to all changes in this revision

Viewing changes to test_asm/test_8515/test_toie0.asm

  • Committer: Bazaar Package Importer
  • Author(s): Shaun Jackman
  • Date: 2004-04-10 13:54:17 UTC
  • Revision ID: james.westby@ubuntu.com-20040410135417-zywapjyz252y65se
Tags: upstream-0.1.2.1
ImportĀ upstreamĀ versionĀ 0.1.2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
;
 
2
; $Id: test_toie0.asm,v 1.2 2003/11/29 09:43:14 troth Exp $
 
3
;
 
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).
 
7
 
 
8
.include        "8515def.inc"
 
9
 
 
10
.equ    zero,   17                              ; r17 preset with 0x00
 
11
.equ    ones,   18                              ; r18 preset with 0xff
 
12
.equ    disp,   19                              ; r19 is output display
 
13
 
 
14
;;; Interrupt Jump Table
 
15
            rjmp    MAIN            ; reset
 
16
        nop                     ; int0
 
17
        nop                     ; int1
 
18
        nop                     ; timer1 capt
 
19
        nop                     ; timer1 compa
 
20
        nop                     ; timer1 compb
 
21
        nop                     ; timer1 ovf
 
22
        rjmp    TIMER_OVF       ; timer0 ovf
 
23
        nop                     ; spi, stc
 
24
        nop                     ; uart, rx
 
25
        nop                     ; uart, udre
 
26
        nop                     ; uart, tx
 
27
        nop                     ; ana_comp
 
28
 
 
29
TIMER_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
 
34
 
 
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
 
38
                ldi             r20, 0x00
 
39
                out             TCCR0, r20              ; set clock select to 0x00 (stop)
 
40
 
 
41
OVF_RETURN:
 
42
                reti                                    ; return from interrupt
 
43
        
 
44
MAIN:
 
45
        ;; init stack pointer to 0x025f (the last byte of int sram)
 
46
                ldi             r16, lo8(RAMEND); low byte of end of int sram
 
47
                out             SPL, r16
 
48
                ldi             r16, hi8(RAMEND); high byte of end of int sram
 
49
                out             SPH, r16
 
50
 
 
51
        ;; preload zero and ones
 
52
                ldi             zero,  0x00
 
53
                ldi             ones,  0xff
 
54
                ldi             disp,  0xff
 
55
        
 
56
        ;; init portb for output
 
57
                out             DDRB,  ones
 
58
                out             PORTB, disp
 
59
 
 
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
 
63
 
 
64
        ;; Enable the Timer0 Overflow interrupt
 
65
                ldi             r20, 1<<TOIE0
 
66
                out             TIMSK, r20              ; set toie0 bit of timsk I/O register
 
67
                sei                                             ; set global interrupt enable (in sreg)
 
68
 
 
69
IDLE_LOOP:
 
70
        ;; Loop until r20 is zero
 
71
                tst             r20
 
72
                brne    IDLE_LOOP
 
73
 
 
74
DONE:
 
75
                rjmp DONE