1 ; Infrared remote control for Nikon D70 with Atmel 8bit MCU
3 ; Copyright (C) 2005, 2006 Michele Bighignoli - Laives (BZ) - ITALY # www.bigmike.it/ircontrol
5 ; Version 2.0.0 - 03/2006
8 ; This program is free software; you can redistribute it and/or modify
9 ; it under the terms of the GNU General Public License as published by
10 ; the Free Software Foundation; either version 2 of the License, or
11 ; (at your option) any later version.
13 ; This program is distributed in the hope that it will be useful,
14 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ; GNU General Public License for more details.
18 ; You should have received a copy of the GNU General Public License
19 ; along with this program; if not, write to the Free Software
20 ; Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 ; Implementation note:
24 ; ---------------------------
25 ; IR led is controlled by PD0 (with NPN transistor).
26 ; Led is "on" when PD0 is high.
28 ; This code has tested with ATTiny2313 and ATMEGA8535 with 8.0 MHz Xtal
30 ; Should work with every Atmel 8bit MCU
35 ; Gerhard Schmidt (DG4FAC) - http://www.avr-asm-tutorial.net/index.html
36 ; Brian Hammill - http://www.ipass.net/~hammill
39 ; WaveForm data (03/2006 version):
41 ; Infrared period = 26us (~38.4kHz)
43 ; Strart pulse: 2000us
55 .
include "tn2313def.inc" ; ATTiny2313
56 ;.include "2313def.inc" ; AT90S2313
67 reti
; ext int 0 (not used)
68 reti
; ext int 1 (not used)
69 reti
; timer1 (not used)
72 reti
; timer0 (not used)
73 reti
; UART RRF Not Used
74 reti
; UART TRE Not Used
75 reti
; UART TRDE Not Used
76 reti
; analog comparator not used
80 ; This is a 13.0 uS delay (104 cycles @ 8MHz)
96 ldi DelayReg
,30 ; 1 cycle
98 dec DelayReg
; 1 cycle
99 brne delay130_loop
; 2 cycle if jump to label, 1 if not
103 ; Code executed at startup
107 ; initialize the stack pointer
109 ; ENABLE IF "SPH" EXISTS
110 ; ldi R16,HIGH(RAMEND)
121 ldi MainLoopC
,2 ; Send a complete waveform 2 times
125 ; Send start pulse (2000 uS)
126 ldi Counter
,77 ; (13 uS * 2 ) * 77 = 2002 uS
129 rcall delay130_led_on
; Wait 13.0 uS
130 cbi PORTD
,0 ; LED off
131 rcall delay130_led_off
; wait 13.0 uS
150 rcall delay130_led_off
152 ; Send first pulse (390 uS)
156 rcall delay130_led_on
157 cbi PORTD
,0 ; LED off
158 rcall delay130_led_off
175 ; Send 2nd pulse (410 uS)
177 ; NOTE: with Counter=16 the pulse width is 416 uS (counting the last "led off" time)
178 ; using Counter=15 and an additional "led on", it's possible to add the last 7 uS (led off) to the pause 2
180 ; Counter=15 = 390 uS +
188 rcall delay130_led_on
189 cbi PORTD
,0 ; LED off
190 rcall delay130_led_off
195 rcall delay130_led_on
196 cbi PORTD
,0 ; LED off
198 ; Pause (3580 uS + 7 uS from pulse2 = 3587 uS)
206 ; Send 3th pulse (400 uS) - (in real world = 403 uS)
210 rcall delay130_led_on
211 cbi PORTD
,0 ; LED off
212 rcall delay130_led_off
217 rcall delay130_led_on
218 cbi PORTD
,0 ; LED off
221 ; No long pause before sleep
237 ; At moment : 63126 uS + 3 uS from pulse3 = 63129 uS
245 ; At moment 63193 uS + 3 uS from pulse3 = 63196 uS
247 ldi Counter
,10 ; 3,75 uS