snippet.asm


1
SetupInt:
2
  sei      ; Bit 7 - I: Global Interrupt Enable,    wird beim eintritt in die interruptroutine gecleart und RETI wieder gesetzt
3
4
  sbx TIMSK, OCIE1A ; Bit 4 - OCE1A: Timer/Counter1 Output CompareA Match Interrupt Enable
5
6
  ldi XH, 0x07    ; initialize compare value : 2000   2.048 MHz / 1024 /2000 = 1 Hz ! ----------- 2000 oder 1999 ?!?!
7
    ldi XL, 0xD0
8
9
    out OCR1AL, XH    ; Timer/Counter1 - Output Compare Register A Low Byte
10
    out OCR1AH, XL    ; Timer/Counter1 - Output Compare Register A High Byte
11
12
13
            ; initialize prescaler
14
              ; Timer/Counter1 Control Register B - TCCR1B   1 0 1 -> CK / 1024
15
    sbx TCCR1B, CS12  ; bit 2
16
    cbx TCCR1B, CS11  ; bit 1
17
    sbx TCCR1B, CS10  ; bit 0
18
    sbx TCCR1B, CTC1  ; Bit 3 - CTC1: Clear Timer/Counter1 on Compare Match
19
20
    clr XL
21
    out TCNT1H, XL    ; clear
22
    out TCNT1L, XL    ; clear
23
24
  ret