; Receive Sony IR Remote Control Codes with Atmel AT90S2313 ; Read key presses and output port b pins 0 - 7 ; This one's for you Randall ; ; Charles R. Ott ; July 11, 1998 .nolist ;Suppress listing of include file .include "2313def.inc" ;Define chip particulars .list ; Function code definitions ; f0 - f7 indicate IR code for port b 0 - 7 outputs ; Change the values for desired key presses ; For example chan+ = 0x10 and chan- = 0x11 ; or vol+ = 0x12 and vol- = 0x13 ; See Sony IR code chart for others .equ f0 =0x00 ;Function key 0 = "1" .equ f1 =0x01 ;Function key 1 = "2" .equ f2 =0x02 ;Function key 2 = "3" .equ f3 =0x03 ;Function key 3 = "4" .equ f4 =0x12 ;Function key 4 = "vol+" .equ f5 =0x13 ;Function key 5 = "vol-" .equ f6 =0x10 ;Function key 6 = "chan+" .equ f7 =0x11 ;Function key 7 = "chan-" ; Constant 'downt' specifies length of time each port pin ; is held high for each key press .equ downt =150 ;Function output debounce time in mS ; Constant 'which' specifies device code (i.e. 0x05 is VCR) .equ which =0x05 ;Sony VCR device code ; Global register variables .def irsaver =R12 ;Save SREG in IR ISR .def saver =R13 ;Save SREG in T1 ISR .def last =R14 ;Last code received .def relays =R15 ;Input port pins for toggling .def wreg =R16 ;General use working register .def devcode =R17 ;IR device code .def irfunc =R18 ;IR function code .def flags =R19 ;Bit variables .def timeout =R20 ;Delay time passed to subroutine .def bitcnt =R21 ;Received character bit counter .def count =R22 ;Count of IR functions received .def temp =R23 ;Temp storage in timer 1 ISR .def ftime0 =R24 ;Function output timers .def ftime1 =R25 .def ftime2 =R26 .def ftime3 =R27 .def ftime4 =R28 .def ftime5 =R29 .def ftime6 =R30 .def ftime7 =R31 ; Flag definitions .equ gotir =0 .equ startb =1 ; Timer/Counter prescaler values .equ TSTOP =0 ;Stop Timer/Counter .equ TCK64 =3 ;Timer/Counter runs from CK / 64 .equ TCK256 =4 ;Timer/Counter runs from CK / 256 .equ TCK1024 =5 ;Timer/Counter runs from CK / 1024 .equ T1VAL =-4 ;Timer 1 reload value .cseg ; Interrupt vectors .org 0 ;Reset Vector Address rjmp reset .org INT0addr ;External Interrupt0 Vector Address rjmp readir .org INT1addr ;External Interrupt1 Vector Address reti .org ICP1addr ;Input Capture1 Interrupt Vector Address reti .org OC1addr ;Output Compare1 Interrupt Vector Address reti .org OVF1addr ;Overflow1 Interrupt Vector Address rjmp timer1 .org OVF0addr ;Overflow0 Interrupt Vector Address reti .org URXCaddr ;UART Receive Complete Interrupt Vector Address reti .org UDREaddr ;UART Data Register Empty Interrupt Vector Address reti .org UTXCaddr ;UART Transmit Complete Interrupt Vector Address reti .org ACIaddr ;Analog Comparator Interrupt Vector Address reti ; Main program entry point on reset reset: ldi wreg,RAMEND ;Init Stack Pointer out SPL,wreg ldi wreg,0x00 ;Turn off all function outputs out PORTB,wreg ldi wreg,0xFF ;Make port B pins all outputs out DDRB,wreg out PORTD,wreg ;Put power on all port D pins ldi wreg,0b11111011 ;Make PD2 an input, all others outputs out DDRD,wreg ldi wreg,1<