1 ; Infrared remote control for Nikon D70 with Atmel 8bit MCU
\r
3 ; Copyright (C) 2005, 2006 Michele Bighignoli - Laives (BZ) - ITALY # www.bigmike.it/ircontrol
\r
5 ; Version 2.0.0-OI - 12/2007
\r
6 ; Modified by Matt Coates (mattjackets+openinterval at gmail.com)
\r
7 ; for use as an include file for the OpenInterval project
\r
8 ; (http://repo.or.cz/w/OpenInterval.git)
\r
10 ; This program is free software; you can redistribute it and/or modify
\r
11 ; it under the terms of the GNU General Public License as published by
\r
12 ; the Free Software Foundation; either version 2 of the License, or
\r
13 ; (at your option) any later version.
\r
15 ; This program is distributed in the hope that it will be useful,
\r
16 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
17 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
18 ; GNU General Public License for more details.
\r
20 ; You should have received a copy of the GNU General Public License
\r
21 ; along with this program; if not, write to the Free Software
\r
22 ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\r
25 ; Implementation note:
\r
26 ; ---------------------------
\r
27 ; IR led is controlled by PD0 (with NPN transistor).
\r
28 ; Led is "on" when PD0 is high.
\r
30 ; This code has tested with ATTiny2313 and ATMEGA8535 with 8.0 MHz Xtal
\r
32 ; Should work with every Atmel 8bit MCU
\r
35 ; Special thanks to:
\r
36 ; ------------------
\r
37 ; Gerhard Schmidt (DG4FAC) - http://www.avr-asm-tutorial.net/index.html
\r
38 ; Brian Hammill - http://www.ipass.net/~hammill
\r
41 ; WaveForm data (03/2006 version):
\r
43 ; Infrared period = 26us (~38.4kHz)
\r
45 ; Strart pulse: 2000us
\r
52 ; longpause: 63200us
\r
58 .DEF MainLoopC = R22
\r
63 ; This is a 13.0 uS delay (104 cycles @ 8MHz)
\r
65 ; sbi/cbi = 2 cycles
\r
79 ldi DelayReg,30 ; 1 cycle
\r
81 dec DelayReg ; 1 cycle
\r
82 brne delay130_loop ; 2 cycle if jump to label, 1 if not
\r
86 ; Code executed at startup
\r
89 ldi MainLoopC,2 ; Send a complete waveform 2 times
\r
93 ; Send start pulse (2000 uS)
\r
94 ldi Counter,77 ; (13 uS * 2 ) * 77 = 2002 uS
\r
96 sbi irport,irpin ; LED on
\r
97 rcall delay130_led_on ; Wait 13.0 uS
\r
98 cbi irport,irpin ; LED off
\r
99 rcall delay130_led_off ; wait 13.0 uS
\r
118 rcall delay130_led_off
\r
120 ; Send first pulse (390 uS)
\r
123 sbi irport,irpin ; LED on
\r
124 rcall delay130_led_on
\r
125 cbi irport,irpin ; LED off
\r
126 rcall delay130_led_off
\r
143 ; Send 2nd pulse (410 uS)
\r
145 ; NOTE: with Counter=16 the pulse width is 416 uS (counting the last "led off" time)
\r
146 ; using Counter=15 and an additional "led on", it's possible to add the last 7 uS (led off) to the pause 2
\r
148 ; Counter=15 = 390 uS +
\r
149 ; "led on" = 13 uS =
\r
155 sbi irport,irpin ; LED on
\r
156 rcall delay130_led_on
\r
157 cbi irport,irpin ; LED off
\r
158 rcall delay130_led_off
\r
162 sbi irport,irpin ; LED on
\r
163 rcall delay130_led_on
\r
164 cbi irport,irpin ; LED off
\r
166 ; Pause (3580 uS + 7 uS from pulse2 = 3587 uS)
\r
174 ; Send 3th pulse (400 uS) - (in real world = 403 uS)
\r
177 sbi irport,irpin ; LED on
\r
178 rcall delay130_led_on
\r
179 cbi irport,irpin ; LED off
\r
180 rcall delay130_led_off
\r
184 sbi irport,irpin ; LED on
\r
185 rcall delay130_led_on
\r
186 cbi irport,irpin ; LED off
\r
189 ; No long pause before sleep
\r
190 breq returnfromshutterrelease
\r
193 ; Pause for 63200 uS
\r
205 ; At moment : 63126 uS + 3 uS from pulse3 = 63129 uS
\r
213 ; At moment 63193 uS + 3 uS from pulse3 = 63196 uS
\r
215 ldi Counter,10 ; 3,75 uS
\r
222 returnfromshutterrelease:
\r