应广单片机红外发射例程,采用PMS150G,其他的MCU型号直接修改就好
//--------------PMS150G----------
// _@
// |1vdd gnd8|
// |2pa7 pa07|
// |3pa6 pa46|–led
// |4pa5____pa35|
#include “extern.h”
led bit pa.4;
word yanshi_a1;
byte kehu;
byte shuju;
void yindao(); //引导码
void fa1(); //发1
void fa0(); //发0
void fasong(); //发送数据
void jieshu(); //结束码
void FPPA0 (void)
{
.ADJUST_IC SYSCLK=IHRC/4 // SYSCLK=IHRC/4
$ led out,low;
while (1)
{
yindao(); //引导码
kehu=8; //客户识别码
while(kehu) //8次0
{
fa0();
}
kehu=8; //8次1
while(kehu)
{
fa1();
}
shuju =0x43; //数据
fasong();
shuju =0xbc; //数据
fasong();
jieshu(); //结束码
/*
led =1;
.delay 73; //109
led =0;
.delay 145;
*/
}
}
/**************************************************/
void yindao() //引导码
{
yanshi_a1 =350;
while(yanshi_a1)
{
led =1;
.delay 73; //109
led =0;
.delay 145;
yanshi_a1 --;
}
led =0;
.delay 18000;
}
/**************************************************/
void fa1() //发1
{
yanshi_a1 =22;
while(yanshi_a1)
{
led =1;
.delay 73; //109
led =0;
.delay 145;
yanshi_a1 --;
}
led =0;
.delay 6720;//2240;
}
/**************************************************/
void fa0() //发0
{
yanshi_a1 =22;
while(yanshi_a1)
{
led =1;
.delay 73; //109
led =0;
.delay 145;
yanshi_a1 --;
}
led =0;
.delay 2240;//2240;
}
/**************************************************/
void fasong() //发送数据
{
if(shuju.0){fa1();} else{fa0();}
if(shuju.2){fa1();} else{fa0();}
if(shuju.3){fa1();} else{fa0();}
if(shuju.4){fa1();} else{fa0();}
if(shuju.5){fa1();} else{fa0();}
if(shuju.6){fa1();} else{fa0();}
}
/**************************************************/
void jieshu() //结束码
{
yanshi_a1 =22;
while(yanshi_a1)
{
led =1;
.delay 73; //109
led =0;
.delay 145;
yanshi_a1 --;
}
}
/**************************************************/
/*
void Interrupt (void)
{
pushaf;
if (Intrq.T16)
{ // T16 Trig
// User can add code
Intrq.T16 = 0;
//...
}
popaf;
}
/
/QQ:1475881755***********/
版权声明:本文为CSDN博主「QiangALL」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_42952848/article/details/121921084
应广单片机红外发射例程,采用PMS150G,其他的MCU型号直接修改就好
//--------------PMS150G----------
// _@
// |1vdd gnd8|
// |2pa7 pa07|
// |3pa6 pa46|–led
// |4pa5____pa35|
#include “extern.h”
led bit pa.4;
word yanshi_a1;
byte kehu;
byte shuju;
void yindao(); //引导码
void fa1(); //发1
void fa0(); //发0
void fasong(); //发送数据
void jieshu(); //结束码
void FPPA0 (void)
{
.ADJUST_IC SYSCLK=IHRC/4 // SYSCLK=IHRC/4
$ led out,low;
while (1)
{
yindao(); //引导码
kehu=8; //客户识别码
while(kehu) //8次0
{
fa0();
}
kehu=8; //8次1
while(kehu)
{
fa1();
}
shuju =0x43; //数据
fasong();
shuju =0xbc; //数据
fasong();
jieshu(); //结束码
/*
led =1;
.delay 73; //109
led =0;
.delay 145;
*/
}
}
/**************************************************/
void yindao() //引导码
{
yanshi_a1 =350;
while(yanshi_a1)
{
led =1;
.delay 73; //109
led =0;
.delay 145;
yanshi_a1 --;
}
led =0;
.delay 18000;
}
/**************************************************/
void fa1() //发1
{
yanshi_a1 =22;
while(yanshi_a1)
{
led =1;
.delay 73; //109
led =0;
.delay 145;
yanshi_a1 --;
}
led =0;
.delay 6720;//2240;
}
/**************************************************/
void fa0() //发0
{
yanshi_a1 =22;
while(yanshi_a1)
{
led =1;
.delay 73; //109
led =0;
.delay 145;
yanshi_a1 --;
}
led =0;
.delay 2240;//2240;
}
/**************************************************/
void fasong() //发送数据
{
if(shuju.0){fa1();} else{fa0();}
if(shuju.2){fa1();} else{fa0();}
if(shuju.3){fa1();} else{fa0();}
if(shuju.4){fa1();} else{fa0();}
if(shuju.5){fa1();} else{fa0();}
if(shuju.6){fa1();} else{fa0();}
}
/**************************************************/
void jieshu() //结束码
{
yanshi_a1 =22;
while(yanshi_a1)
{
led =1;
.delay 73; //109
led =0;
.delay 145;
yanshi_a1 --;
}
}
/**************************************************/
/*
void Interrupt (void)
{
pushaf;
if (Intrq.T16)
{ // T16 Trig
// User can add code
Intrq.T16 = 0;
//...
}
popaf;
}
/
/QQ:1475881755***********/
版权声明:本文为CSDN博主「QiangALL」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weixin_42952848/article/details/121921084
暂无评论