Сделал полгода назад с нуля код с целью автоматического захода в сервис меню и factory reset
протокол у телика был как раз класический NEC
там ATtiny24A
НО управление чисто софтовыми задержками . без таймеров
а значит пойдет любой АVR c тактовой от 8мГц (возможно и 4 но тогда на пару процентов уйдут тайминги относительно стандартных)
всего то нужно изменить дефайны
#define LED_ON PORTB.0 =1; /// Пин куда подключен светодиод
#define LED_OFF PORTB.0 =0;
Для наглядности в ходе тестов можно брать белый изи красный светодиод
вблизи будет срабатывать .В конце поставить инфракрасный
Адрес девайса можно узнать сторонними программами типа RCExplorer
имея родной пульт
в моем случае адрес 0x40 (одно из шасси Vestel)
Программа вне зависимости от состояния ТВ его вкключает ждет загрузку входит в сервис меню и делает фатори ресет
Код: Выделить всё
/*******************************************************
This program was created by the
CodeWizardAVR V3.10 Advanced
Automatic Program Generator
© Copyright 1998-2014 Pavel Haiduc, HP InfoTech s.r.l.
http://www.hpinfotech.com
Project :
Version :
Date : 20.03.2016
Author :
Company :
Comments:
Chip type : ATtiny24A
AVR Core Clock frequency: 8,000000 MHz
Memory model : Tiny
External RAM size : 0
Data Stack size : 32
*******************************************************/
#include
#include
// Declare your global variables here
unsigned int k;
#define LED_ON PORTB.0 =1;
#define LED_OFF PORTB.0 =0;
void IR_4Byte_OUT (unsigned char adr_in,unsigned char cmd_in ) ;
void ReP_OUT () ;
// Timer 0 overflow interrupt service routine
interrupt [TIM0_OVF] void timer0_ovf_isr(void)
{
// Reinitialize Timer 0 value
TCNT0=0x29;
// Place your code here
}
void main(void)
{
// Declare your local variables here
// Crystal Oscillator division factor: 1
#pragma optsize-
CLKPR=(1<
// delay_ms(38);
// ReP_OUT () ;
// delay_ms(96);
// ReP_OUT () ;
// delay_ms(96);
// ReP_OUT () ;
// delay_ms(96);
// ReP_OUT () ;
// delay_ms(96);
// ReP_OUT () ;
// delay_ms(96);
// ReP_OUT () ;
// delay_ms(96);
// ReP_OUT () ;
// delay_ms(96);
// ReP_OUT () ;
// delay_ms(96);
// ReP_OUT () ;
// delay_ms(12000);
// IR_4Byte_OUT(0x40,0x12); // on/off
// IR_4Byte_OUT(0x40,0x43); // exit
// IR_4Byte_OUT(0x40,0x14); // sourse
delay_ms(8000);
IR_4Byte_OUT(0x40,0x01); // 1
delay_ms(38);
ReP_OUT () ;
delay_ms(96);
ReP_OUT () ;
delay_ms(96);
delay_ms(600);
IR_4Byte_OUT(0x40,0x43); // exit
delay_ms(600);
IR_4Byte_OUT(0x40,0x43); // exit
delay_ms(17000);
IR_4Byte_OUT(0x40,0x5b); //menu
delay_ms(40);
ReP_OUT () ;
delay_ms(96);
ReP_OUT () ;
delay_ms(96);
ReP_OUT () ;
ReP_OUT () ;
delay_ms(96);
ReP_OUT () ;
delay_ms(96);
ReP_OUT () ;
delay_ms(96);
ReP_OUT () ;
delay_ms(96);
ReP_OUT () ;
delay_ms(96);
ReP_OUT () ;
delay_ms(96);
ReP_OUT () ;
delay_ms(900);
IR_4Byte_OUT(0x40,0x04);
delay_ms(400);
IR_4Byte_OUT(0x40,0x07);
delay_ms(400);
IR_4Byte_OUT(0x40,0x02);
delay_ms(400);
IR_4Byte_OUT(0x40,0x05);
delay_ms(900);
IR_4Byte_OUT(0x40,0x40); //-->
delay_ms(600);
IR_4Byte_OUT(0x40,0x1d);
delay_ms(600);
IR_4Byte_OUT(0x40,0x1d);
delay_ms(600);
IR_4Byte_OUT(0x40,0x1d);
delay_ms(600);
IR_4Byte_OUT(0x40,0x1d);
delay_ms(600);
IR_4Byte_OUT(0x40,0x1d);
delay_ms(600);
IR_4Byte_OUT(0x40,0x1d);
delay_ms(600);
IR_4Byte_OUT(0x40,0x1d);
delay_ms(600);
IR_4Byte_OUT(0x40,0x1d);
delay_ms(600);
IR_4Byte_OUT(0x40,0x1d);
delay_ms(600);
IR_4Byte_OUT(0x40,0x1d);
delay_ms(600);
IR_4Byte_OUT(0x40,0x21); //ok
delay_ms(600);
IR_4Byte_OUT(0x40,0x43); // exit
delay_ms(600);
IR_4Byte_OUT(0x40,0x43); // exit
delay_ms(2000);
IR_4Byte_OUT(0x40,0x14); // sourse
delay_ms(600);
IR_4Byte_OUT(0x40,0x14); // sourse
delay_ms(600);
IR_4Byte_OUT(0x40,0x14); // sourse
delay_ms(600);
IR_4Byte_OUT(0x40,0x14); // sourse
delay_ms(600);
IR_4Byte_OUT(0x40,0x14); // sourse
delay_ms(600);
IR_4Byte_OUT(0x40,0x14); // sourse
delay_ms(600);
IR_4Byte_OUT(0x40,0x14); // sourse
delay_ms(600);
IR_4Byte_OUT(0x40,0x21); //ok
// IR_4Byte_OUT(0x40,0x40); //-->
// delay_ms(60000);
// IR_4Byte_OUT(0x40,0x42); //<--
// delay_ms(1000);
// delay_ms(40);
// ReP_OUT () ;
// PORTB.2=0;
}
}
//
void IR_4Byte_OUT (unsigned char adr_in,unsigned char cmd_in )
{
unsigned char bitcnt;
unsigned char adr_store;
unsigned char cmd_store;
unsigned char counter;
adr_store=adr_in;cmd_store=cmd_in;
for (counter=0;counter<255;counter++) //9000 uSec block len ((255+78)* (7+19))
{ LED_ON; delay_us(7); LED_OFF; delay_us(19); } //led blink 38kHz ; Duty cycle 1/3.5
for (counter=0;counter<78;counter++)
{ LED_ON; delay_us(7); LED_OFF; delay_us(19); } //led blink 38kHz ; Duty cycle 1/3.5
delay_us(1000); delay_us(1000); delay_us(1000); delay_us(1000); delay_us(490); //4500u Sec pause
// adress transmitt
for (bitcnt=0; bitcnt<8; bitcnt++)
{ for (counter=0;counter<21;counter++) //26 uSec =T 38kHz //560 uSec block len /21 pulse
{ LED_ON; delay_us(7); LED_OFF; delay_us(19); } //led blink 560uSec; carier 38kHz ; Duty cycle 1/3.
if ((adr_in & 0x01)==0x01) {delay_us(1689);} //1 pause 1690 uS
else {delay_us(559);} // 0 pause 560 uS
adr_in=adr_in>>1;
}
adr_in= adr_store;
for (bitcnt=0; bitcnt<8; bitcnt++)
{ for (counter=0;counter<21;counter++) //26 uSec =T 38kHz //560 uSec block len /21 pulse
{ LED_ON; delay_us(7); LED_OFF; delay_us(19); } //led blink 560uSec; carier 38kHz ; Duty cycle 1/3.
if ((adr_in & 0x01)==0x01) {delay_us(559);} //invert pause
else {delay_us(1689);}
adr_in=adr_in>>1;
}
// command transmitt
for (bitcnt=0; bitcnt<8; bitcnt++)
{ for (counter=0;counter<21;counter++) //26 uSec =T 38kHz //560 uSec block len /21 pulse
{ LED_ON; delay_us(7); LED_OFF; delay_us(19); } //led blink 560uSec; carier 38kHz ; Duty cycle 1/3.
if ((cmd_in & 0x01)==0x01) {delay_us(1689);} //1 pause 1690 uS
else {delay_us(559);} // 0 pause 560 uS
cmd_in=cmd_in>>1;
}
cmd_in= cmd_store;
for (bitcnt=0; bitcnt<8; bitcnt++)
{ for (counter=0;counter<21;counter++) //26 uSec =T 38kHz //560 uSec block len /21 pulse
{ LED_ON; delay_us(7); LED_OFF; delay_us(19); } //led blink 560uSec; carier 38kHz ; Duty cycle 1/3.
if ((cmd_in & 0x01)==0x01) {delay_us(559);} //invert pause
else {delay_us(1689);}
cmd_in=cmd_in>>1;
}
// final 562.5µs pulse burst to signify the end of message transmission.
for (counter=0;counter<21;counter++) // //26 uSec =T 38kHz //560 uSec block len /21 pulse
{ LED_ON; delay_us(7); LED_OFF; delay_us(19); } //led blink 38kHz ; Duty cycle 1/3.5
}
void ReP_OUT ()
{
unsigned char counter;
for (counter=0;counter<255;counter++) //9000 uSec block len ((255+80)* (7+19))
{ LED_ON; delay_us(7); LED_OFF; delay_us(19); } //led blink 38kHz ; Duty cycle 1/3.5
for (counter=0;counter<78;counter++)
{ LED_ON; delay_us(7); LED_OFF; delay_us(19); } //led blink 38kHz ; Duty cycle 1/3.5
delay_us(1000); delay_us(1000); delay_us(230); //2250u Sec pause
// final 562.5µs pulse burst to signify the end of message transmission.
for (counter=0;counter<21;counter++) // //26 uSec =T 38kHz //560 uSec block len /21 pulse
{ LED_ON; delay_us(7); LED_OFF; delay_us(19); } //led blink 38kHz ; Duty cycle 1/3.5
}
ух ты.... показывает