Interval set by example. ATtiny13 RC Oscillator.
[OpenInterval.git] / cameras / Nikon_OML-L3.inc
blob56a9109852e0424163fb00e2eb5c86f232a58d5e
1 ; Infrared remote control for Nikon D70 with Atmel 8bit MCU
2
3 ; Copyright (C) 2005, 2006 Michele Bighignoli - Laives (BZ) - ITALY # www.bigmike.it/ircontrol
5 ; Version 2.0.0-OI - 12/2007
6 ; Modified by Matt Coates (mattjackets+openinterval at gmail.com)
7 ; for use as an include file for the OpenInterval project
8 ; (http://repo.or.cz/w/OpenInterval.git)
10 ; This program is free software; you can redistribute it and/or modify
11 ; it under the terms of the GNU General Public License as published by
12 ; the Free Software Foundation; either version 2 of the License, or
13 ; (at your option) any later version.
15 ; This program is distributed in the hope that it will be useful,
16 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 ; GNU General Public License for more details.
20 ; You should have received a copy of the GNU General Public License
21 ; along with this program; if not, write to the Free Software
22 ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
25 ; Implementation note:
26 ; ---------------------------
27 ; IR led is controlled by PD0 (with NPN transistor).
28 ; Led is "on" when PD0 is high.
30 ; This code has tested with ATTiny2313 and ATMEGA8535 with 8.0 MHz Xtal
32 ; Should work with every Atmel 8bit MCU
35 ; Special thanks to:
36 ; ------------------
37 ; Gerhard Schmidt (DG4FAC) - http://www.avr-asm-tutorial.net/index.html
38 ; Brian Hammill - http://www.ipass.net/~hammill
41 ; WaveForm data (03/2006 version):
43 ; Infrared period = 26us (~38.4kHz)
45 ; Strart pulse:  2000us
46 ; pause:                27830us
47 ; 1st pulse:      390us
48 ; pause:                 1580us
49 ; 2nd pulse:      410us
50 ; pause:                 3580us
51 ; 3rd pulse:      400us
52 ; longpause:    63200us
53
54 ; REPEAT ONE TIME
57 .DEF DelayReg  = R24
58 .DEF MainLoopC = R23
59 .DEF Counter   = R22
60 .DEF Counter2  = R21
62 delay130:
63 ; This is a 13.0 uS delay (104 cycles @ 8MHz)
65 ; sbi/cbi = 2 cycles
66 ; rcall = 3 cycles
68         nop
69         nop
71 delay130_led_on:
72         nop
73         nop
74         nop
76 delay130_led_off:
77         nop
78         nop
79         nop
80         nop
81         ret                             ; 4 cycles
84 ; Code executed at startup
86 shutterrelease:
87         ldi     MainLoopC,2             ; Send a complete waveform 2 times
89 mainloop:
91 ; Send start pulse (2000 uS)
92         ldi     Counter,77              ; (13 uS * 2 ) * 77 = 2002 uS
93 startpulse:
94         sbi     irport,irpin                    ; LED on
95         rcall   delay130_led_on         ; Wait 13.0 uS
96         cbi     irport,irpin                    ; LED off
97         rcall   delay130_led_off                ; wait 13.0 uS
98         dec     Counter
99         brne    startpulse
101 ; Pause (27830 uS)
102         ldi     Counter,237
103 startpause:
104         rcall   delay130
105         rcall   delay130
106         rcall   delay130
107         rcall   delay130
108         rcall   delay130
109         rcall   delay130
110         rcall   delay130
111         rcall   delay130
112         rcall   delay130
113         dec     Counter
114         brne    startpause
116         rcall   delay130_led_off
118 ; Send first pulse (390 uS)
119         ldi     Counter,15
120 pulse1:
121         sbi     irport,irpin                    ; LED on
122         rcall   delay130_led_on
123         cbi     irport,irpin                    ; LED off
124         rcall   delay130_led_off
125         dec     Counter
126         brne    pulse1
128 ; Pause (1580 uS)
129         ldi     Counter,118
130 pause1:
131         rcall   delay130
132         dec     Counter
133         brne    pause1
135         ldi     Counter,5
136 pause1b:
137         dec     Counter
138         brne    pause1b
141 ; Send 2nd pulse (410 uS)
143 ; NOTE: with Counter=16 the pulse width is 416 uS (counting the last "led off" time)
144 ; using Counter=15 and an additional "led on", it's possible to add the last 7 uS (led off) to the pause 2
146 ; Counter=15 = 390 uS +
147 ; "led on"   =  13 uS =
148 ; TOTAL      = 403 uS
151         ldi     Counter,15
152 pulse2:
153         sbi     irport,irpin                    ; LED on
154         rcall   delay130_led_on
155         cbi     irport,irpin                    ; LED off
156         rcall   delay130_led_off
157         dec     Counter
158         brne    pulse2
160         sbi     irport,irpin                    ; LED on
161         rcall   delay130_led_on
162         cbi     irport,irpin                    ; LED off
164 ; Pause (3580 uS + 7 uS from pulse2 = 3587 uS)
165         ldi     Counter,136
166 pause2:
167         rcall   delay130
168         rcall   delay130
169         dec     Counter
170         brne    pause2
172 ; Send 3th pulse (400 uS) - (in real world = 403 uS)
173         ldi     Counter,15
174 pulse3:
175         sbi     irport,irpin                    ; LED on
176         rcall   delay130_led_on
177         cbi     irport,irpin                    ; LED off
178         rcall   delay130_led_off
179         dec     Counter
180         brne    pulse3
182         sbi     irport,irpin                    ; LED on
183         rcall   delay130_led_on
184         cbi     irport,irpin                    ; LED off
186         dec     MainLoopC
187 ; No long pause before sleep
188         breq    returnfromshutterrelease
191 ; Pause for 63200 uS
192         ldi     Counter,239
193 longpause:
194         ldi     Counter2,10
195 longpause1:     
196         rcall   delay130
197         rcall   delay130
198         dec     Counter2
199         brne    longpause1
200         dec     Counter
201         brne    longpause
203 ; At moment : 63126 uS + 3 uS from pulse3 = 63129 uS
205         ldi     Counter,5
206 longpause2:
207         rcall   delay130
208         dec     Counter
209         brne    longpause2
211 ; At moment 63193 uS + 3 uS from pulse3 = 63196 uS
213         ldi     Counter,10              ; 3,75 uS
214 longpause3:
215         dec     Counter
216         brne    longpause3
217         
218         rjmp    mainloop
220 returnfromshutterrelease:
221         ret