//应广单片机编程第七季
//试商法,逆向工程,红外发射
//QQ:774145445
//快手:共同学习stm8
//2020/11/8
//--------------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;
}
*/
|