97b4d956c597e4663565bc24396e94dc862d1b48
[my-code/atmel.git] / monolyzer / main.asm
1 ; main file of the monolyzer project
2 ;
3 ; author: hackbard@hackdaworld.org
4 ;
5
6 ; device specific definition file
7 .include "../include/tn2313def.inc"
8
9 ; defines
10 .def    zero            = r1
11 .def    one             = r2
12 .def    tmp1            = r16
13 .def    tmp2            = r17
14 .def    uart_rxtx       = r18
15 .def    count           = r19
16
17 ;
18 ; interrupts
19 ;
20
21 ; RESET
22 rjmp INIT
23
24 ; INT0
25 reti
26
27 ; INT1
28 reti
29
30 ; T1 CAPT1
31 reti
32
33 ; T1 COMP A
34 reti
35
36 ; T1 OVF1
37 reti
38
39 ; T0 OVF0
40 rjmp T0_OVF
41
42 ; UART RX
43 rjmp UART_RECEIVE
44
45 ; UART UDRE
46 reti
47
48 ; UART TX
49 reti
50
51 ; ANA COMP
52 reti
53
54 ; PCINT
55 reti
56
57 ; T1 COMP B
58 reti
59
60 ; T0 COMP A
61 reti
62
63 ; T0 COMP B
64 reti
65
66 ; USI START
67 reti
68
69 ; USI OVF
70 reti
71
72 ; EE READY
73 reti
74
75 ; WDT OVF
76 reti
77
78 ;
79 ; init and main code
80 ;
81
82 RESET:
83 INIT:
84
85         ; gio port init
86         rcall PORT_INIT
87
88         ; timer0 init
89         rcall TIMER0_INIT
90
91         ; timer0 interrupt enable
92         rcall TIMER0_INT_INIT
93
94         ; uart init
95         rcall UART_INIT
96
97         ; uart interrupt enable
98         rcall UART_INT_RX_INIT
99
100         ; zero and one initialization
101         ldi tmp1,0
102         mov zero,tmp1
103         ldi tmp1,1
104         mov one,tmp1
105
106         ; set stackpointer
107         ldi tmp1,low(RAMEND)
108         out SPL,tmp1
109
110         ; more init
111         ldi count,0x21
112
113         ; signal ready output
114         ldi uart_rxtx,0x68
115         rcall UART_TX
116
117         ; global interrupt enable
118         sei 
119
120 MAIN:
121
122 WAIT_FOR_HIGH:
123         ; start as soon as we get a high signal
124
125         rjmp WAIT_FOR_HIGH
126
127
128 ; include subroutines
129 .include "port.asm"
130 .include "timer.asm"
131 .include "uart.asm"
132
133
134 ;
135 ; interrupt routines
136 ;
137
138 T0_OVF:
139
140         ; debug output
141         cbi PORTD,3
142
143         ; read port
144
145         ; store another byte into sram
146
147
148         ; debug output
149         sbi PORTD,3
150         
151         reti
152
153 UART_RECEIVE:
154         reti
155
156
157 ;
158 ; sram
159 ;
160
161 .dseg
162
163 DATA_STORAGE: .byte 8
164
165