;OK TV Remote ; ;Format NEC ; ;The NEC IR transmission protocol uses pulse distance encoding of the message bits. Each pulse burst (mark – RC transmitter ON) is 562.5µs in length, ;at a carrier frequency of 38kHz (26.3µs). Logical bits are transmitted as follows: ; ;Logical '0' – a 562.5µs pulse burst followed by a 562.5µs space, with a total transmit time of 1.125ms ;Logical '1' – a 562.5µs pulse burst followed by a 1.6875ms space, with a total transmit time of 2.25ms ; ;When a key is pressed on the remote controller, the message transmitted consists of the following, in order: ; ;a 9ms leading pulse burst (16 times the pulse burst length used for a logical data bit) ;a 4.5ms space ;the 8-bit address for the receiving device ;the 8-bit logical inverse of the address ;the 8-bit command ;the 8-bit logical inverse of the command ;a final 562.5µs pulse burst to signify the end of message transmission. ;The four bytes of data bits are each sent least significant bit first. ;------------------------------------------------------------------------------------------ ;Pinout ATTiny24 ; -------U------- ; VCC |1 VCC GND 14| GND ; |2 PB0 PA0 13| SW1 ; |3 PB1 PA1 12| SW2 ; |4 PB3 PA2 11| SW3 ;IR-LED |5 PB2 PA3 10| SW4 ; |6 PA7 PA4 9| SW5 ; SW7 |7 PA6 PA5 8| SW6 ; --------------- ; ;------------------------------------------------------------------------------------------ ;SW1 POWER / INPUT ;SW2 CH+ / UP ;SW3 CH- / DOWN ;SW4 VOL+ / RIGHT ;SW5 VOL- / LEFT ;SW6 MUTE / OK ;SW7 ALT ; CPUFREQ: RC OSC 8MHz .include "tn24def.inc" .def cmd_2 = R0 .def cmd_1 = R1 .def adr_2 = R2 .def adr_1 = R3 .def temp = R16 .def key = R17 .def count = R18 .def alt_flag = R19 .org 0x0000 rjmp init .org PCI0addr rjmp PCINT_ISR init: ;setup stack ldi temp, LOW(RAMEND) out SPL, temp ;setup ports ldi temp, 0x00 out DDRA, temp ;Port A input ldi temp, 0xff out PORTA, temp ;enable pullups ldi temp, 0b00000000 out DDRB, temp ;Port B input ldi temp, 0b00000011 out PORTB, temp ;enable pullups ;setup timer 0: 38 kHz on OC0A Pin PB2 @ 8MHz ldi temp, 105+1 out OCR0A, temp ldi temp, 1<