Interval set by example. ATtiny13 RC Oscillator.
[OpenInterval.git] / openinterval.asm
blob5b258eb409682d929f5e8f282b7fe41c30933a10
1 ; OpenInterval
3 ; Copyright 2007 Matthew F. Coates (mattjackets+openinterval at gmail.com)
5 ; This program is free software: you can redistribute it and/or modify
6 ; it under the terms of the GNU General Public License as published by
7 ; the Free Software Foundation, either version 3 of the License, or
8 ; (at your option) any later version.
10 ; This program is distributed in the hope that it will be useful,
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ; GNU General Public License for more details.
15 ; You should have received a copy of the GNU General Public License
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
18 .include "include/tn13def.inc"
19 .EQU buttonPin = 1 ; button
20 .EQU syncPin = 3 ; sync LED port
21 .EQU irPort = PORTB; ir LED port
22 .EQU irPin = 4 ; ir LED pin
23 .equ freq = 2;
25 .def mode = r16
26 .def tcounter = r17
27 .def tcounter2 = r18
28 .def Idelay = r19
29 .def Idelay2 = r20
32 .cseg
33 .org 0x0000
35 reset:
36 rjmp init ; Reset handler
37 rjmp INT0_hand ; INT0 handler
38 reti ; Pin change handler
39 rjmp TIM0_OVF ; Timer overflow handler
40 reti ; EEPROM Ready handler
41 reti ; Analog Comparator handler
42 reti ; Timer/Counter Compare Match A handler
43 reti ; Timer/Counter Compare Match B handler
44 reti ; Watchdog Time-out handler
45 reti ; ADC Conversion Complete handler
48 ;camera include file goes here
49 .include "cameras/Nikon_OML-L3.inc"
51 init:
52 ldi mode, low(ramend)
53 out spl, mode
54 ; enable sleep mode and INT0 on falling edge
55 ldi mode, (1 << SE) | (1 << ISC01)
56 out MCUCR, mode
58 ; disable ACD
59 ldi mode, (1 << ACD)
60 out ACSR, mode
62 ; enable timer0
63 ldi mode, 0
64 out TCNT0, mode
66 ; set timer prescaler 1024
67 ldi mode, (1 << CS02) | (1 << CS00)
68 out TCCR0B, mode
70 ; reset timer
71 ldi mode, 0
72 out TCNT0, mode
74 ; enable INT0 interrupt
75 ldi mode, (1 << INT0)
76 out GIMSK, mode
78 ; Set portB input
79 sbi PORTB,buttonPin ; set b4 config. to enable internal pull-up.
80 cbi DDRB,buttonPin
81 ; Set portB output
82 sbi DDRB,irPin
83 sbi DDRB,syncPin
84 sbi DDRB,2
86 sbi irPort,irPin ; LED off
87 ldi tcounter,0
88 ldi tcounter2,1
89 ldi Idelay,0
90 ldi Idelay2,1
91 ldi mode,0
93 sei
96 testloop:
97 sbi irPort,syncPin
98 rcall shutterrelease
99 cbi irPort,syncPin
100 ; rcall longdelay
101 ; rjmp testloop
104 GoToSleep:
105 sleep
106 rjmp GoToSleep
108 TIM0_OVF:
110 cpi mode,0
111 breq ReturnFI
112 cpi mode,1
113 breq Timing
114 cbi irport,syncPin
115 cpi tcounter, 0
116 brne SKIP
117 cpi tcounter2,0
118 brne SKIP
119 sbi irport,syncPin
120 mov tcounter, Idelay
121 mov tcounter2, Idelay2
122 rcall shutterrelease
123 SKIP:
124 dec tcounter
125 brne ReturnFI
126 dec tcounter2
127 reti
128 Timing:
129 inc Idelay
130 brne ReturnFI
131 inc Idelay2
132 reti
134 ReturnFI:
135 reti
136 LongDelay:
137 ldi Counter,255
138 intpause:
139 rcall delay130
140 rcall delay130
141 rcall delay130
142 rcall delay130
143 rcall delay130
144 rcall delay130
145 rcall delay130
146 rcall delay130
147 rcall delay130
148 rcall delay130
149 rcall delay130
150 rcall delay130
151 rcall delay130
152 rcall delay130
153 rcall delay130
154 rcall delay130
155 rcall delay130
156 rcall delay130
157 rcall delay130
158 rcall delay130
159 rcall delay130
160 rcall delay130
161 rcall delay130
162 rcall delay130
163 rcall delay130
164 dec Counter
165 brne intpause
168 INT0_hand:
169 rcall longdelay
170 brne intpause
171 cpi mode,2
172 breq ReturnFI
173 cpi mode,1
174 breq setDelay
175 ldi mode,1
176 ; enable timer overflow
177 ldi tcounter, (1 << TOIE0)
178 out TIMSK0, tcounter
179 sbi irport,syncpin
180 reti
181 setDelay:
182 cbi irport,syncpin
183 ldi mode,2
184 ldi tcounter,0
185 ldi tcounter2,0
186 reti