سلام دوستان من یه گیرنده rc5 دارم به شماره 138BB170304 اما نمیدونم فرکانس حاملش چقدره ایا اون عدد 304 اخر اندازه فرکانس هست یا خیر
با تشکر
با تشکر
oo:
oo:
oo:
oo: (فعلا به این مرحله :angry:نرسیده)
unsigned char bin_add[8],bin_com[8];
unsigned char i,c,T=221;
bit g=1;
#define IRoutput PORTD.0 //Config Port
void dec_to_bin(unsigned char a, unsigned char op){
unsigned char b,c,i=7;
while(i<255){ //from 7 to 0 ==> Decrement from 0 == 255
b=a/2;
c=a%2;
if(op==1) bin_add[i]=c; //select variable addres
else if (op==2) bin_com[i]=c; //select variable command
a=b;
if(a==1) { //if lasted Division=1
i--;
if(op==1) bin_add[i]=1;
else if (op==2) bin_com[i]=1;
a=0;
}
i--;
}
}
interrupt [TIM0_OVF] void timer0_ovf_isr(void){
if(g==1) IRoutput=~IRoutput; //F=35.7 Khz
else IRoutput=1;
TCNT0=T; //Delay for 14us
c++;
}
void modul_0(){ //send logic 0 whit modulation
g=1; c=0;
TCNT0=T;
Label_01: if(c<=64) goto Label_01;
c=g=0;
Label_02: if(c<=64) goto Label_02;
}
void modul_1(){ //send logic 1 whit modulation
c=g=0;
TCNT0=T;
Label_11: if(c<=64) goto Label_11;
g=1; c=0;
Label_12: if(c<=64) goto Label_12;
}
void address(){
for(i=3; i<8; i++){
if(bin_add[i]==0) modul_0();
else if (bin_add[i]==1) modul_1();
}
}
void command(){
for(i=2; i<8; i++){
if(bin_com[i]==0) modul_0();
else if (bin_com[i]==1) modul_1();
}
}
void sendrc5(unsigned char tog, unsigned char add, unsigned char com){
dec_to_bin(add,1); // 1= insert to bin_add
dec_to_bin(com,2); // 2= insert to bin_com
#asm("sei")
modul_1(); //chek bit
modul_1(); //chek bit
if(tog==0) modul_0(); //toggle bit=0 //110 xxxxx xxxxxx total 14bit
else if(tog==1) modul_1(); //toggle bit=1 //111 xxxxx xxxxxx total 14bit
address();
command();
#asm("cli")
IRoutput=0;
delay_ms(30);
}
unsigned char x,y; DDRD.0=1; //output PIN 0 Of PORTD IRoutput=0; TCCR0=0x01; TCNT0=T; TIMSK=0x01; sendrc5(0,x,y); //toggle, address, command
unsigned char bin_add[8],bin_com[8];
unsigned char i,c,T=221;
bit g=1;
#define IRoutput PORTD.0 //Config Port
void dec_to_bin(unsigned char a, unsigned char op){
unsigned char b,c,i=7;
while(i<255){ //from 7 to 0 ==> Decrement from 0 == 255
b=a/2;
c=a%2;
if(op==1) bin_add[i]=c; //select variable addres
else if (op==2) bin_com[i]=c; //select variable command
a=b;
if(a==1) { //if lasted Division=1
i--;
if(op==1) bin_add[i]=1;
else if (op==2) bin_com[i]=1;
a=0;
}
i--;
}
}
interrupt [TIM0_OVF] void timer0_ovf_isr(void){
if(g==1) IRoutput=~IRoutput; //F=35.7 Khz
else IRoutput=1;
TCNT0=T; //Delay for 14us
c++;
}
void modul_0(){ //send logic 0 whit modulation
g=1; c=0;
TCNT0=T;
Label_01: if(c<=64) goto Label_01;
c=g=0;
Label_02: if(c<=64) goto Label_02;
}
void modul_1(){ //send logic 1 whit modulation
c=g=0;
TCNT0=T;
Label_11: if(c<=64) goto Label_11;
g=1; c=0;
Label_12: if(c<=64) goto Label_12;
}
void address(){
for(i=3; i<8; i++){
if(bin_add[i]==0) modul_0();
else if (bin_add[i]==1) modul_1();
}
}
void command(){
for(i=2; i<8; i++){
if(bin_com[i]==0) modul_0();
else if (bin_com[i]==1) modul_1();
}
}
void sendrc5(unsigned char tog, unsigned char add, unsigned char com){
dec_to_bin(add,1); // 1= insert to bin_add
dec_to_bin(com,2); // 2= insert to bin_com
#asm("sei")
modul_1(); //chek bit
modul_1(); //chek bit
if(tog==0) modul_0(); //toggle bit=0 //110 xxxxx xxxxxx total 14bit
else if(tog==1) modul_1(); //toggle bit=1 //111 xxxxx xxxxxx total 14bit
address();
command();
#asm("cli")
IRoutput=0;
delay_ms(30);
}
unsigned char x,y; DDRD.0=1; //output PIN 0 Of PORTD IRoutput=0; TCCR0=0x01; TCNT0=T; TIMSK=0x01; sendrc5(0,x,y); //toggle, address, command
دیدگاه