licht_attiny_test.asm


1
.nolist
2
.include <tn2313def.inc>
3
.list
4
.cseg
5
.def gefahr=r13
6
.def alt=r14
7
.def prelltest=r15
8
.def zahl=r21
9
.def prell=r17
10
.def temp=r16
11
.def sregsave=r19
12
.def tmp=r18
13
.def tast=r20
14
.DEF BL=R24
15
.DEF BH=R25
16
.org 0x000  
17
18
19
      rjmp RESET
20
         rjmp RESET
21
      rjmp RESET
22
      rjmp RESET
23
      rjmp RESET
24
      rjmp RESET
25
      rjmp RESET
26
      rjmp Licht_80s
27
      rjmp RESET
28
      rjmp RESET
29
      rjmp RESET
30
      rjmp RESET
31
      rjmp RESET
32
      rjmp RESET
33
reset:
34
    ldi prell,50
35
    ldi zahl,50
36
    ldi temp,128
37
    out SREG,temp      ;legt die umläüfe des timers fest        ;also auch die zeit wie lange die lampe brennt  
38
      ldi temp, low(ramend)
39
      out spl, temp
40
  
41
    ldi temp,0b11111111    ; portb ist ausgang
42
    out ddrb,temp  
43
    
44
    ldi temp,0b00000000
45
    out ddrd,temp      ;portd ist eingang
46
    
47
    ldi Temp, 2        ;hier wird der timer interupt freigegeben
48
    out TIMSK, Temp  
49
50
    ldi temp,5
51
    out TCCR0,temp      ; mit 1024 geteilte frequenz
52
    
53
    ldi temp,0b00000101    ; timer1 mit 1024 teilen
54
    out TCCR1B,temp
55
    
56
    rjmp licht
57
    
58
Licht:
59
60
      push tmp
61
       push sregsave          
62
       in sregsave ,SREG        
63
       ldi tmp , 255
64
       out TCNT0, tmp        
65
       out SREG, sregsave          
66
       pop sregsave
67
        pop tmp
68
69
  
70
Licht_80s:  mov zahl,prell
71
      dec zahl
72
      mov prell,zahl
73
      ldi temp,0
74
      cp zahl,temp
75
      breq licht_aus
76
      rjmp licht
77
78
licht_aus:
79
           ldi temp,0b11111111
80
       out portb,temp
81
       rjmp ende
82
83
ende:  
84
    
85
    rjmp ende