做过的一个项目,
用做全频段发射的。控制器用三星的。
typedef unsigned char Uchar;
typedef unsigned int Uint;
static const Uint __code CHANNEL_TABLE[]={870, 880, 890, 900, 910, 920, 930,
940, 950, 960, 970, 980, 990, 1000,
1010,1020,1030,1040,1050,1060,1070};
#define EN_ON() P2 |=0x01
#define EN_OFF() P2 &=0xFE
#define CLK_HIGH() P2 |=0x02
#define CLK_LOW() P2 &=0xFD
#define DATA_HIGH() P2 |=0x04
#define DATA_LOW() P2 &=0xFB
//============================================
static void _Transmt_once(Uint DataFr)
{
Uchar i;
EN_ON();
DATA_LOW();
for(i = 0; i < 16; i++)
{
CLK_LOW();
if(DataFr & 0x01)
DATA_HIGH();
else
DATA_LOW();
DataFr>>=1;
CLK_HIGH();
}
CLK_LOW();
DATA_LOW();
EN_OFF();
}
//==================================================
//ChanH===(00(88)---22(108)) ChanL===(0(.0)---9(.9))
//==================================================
void Transmt_Channel(Uchar ChanH,Uchar ChanL)
{
Uint Frequency;
if(ChanH < sizeof(CHANNEL_TABLE)/sizeof(CHANNEL_TABLE[0]))
{
Frequency = CHANNEL_TABLE[ChanH];
Frequency |=(Uint)(0x48 << 8); //最高5位为操作控制码
Frequency +=(Uint)ChanL;
_Transmt_once(Frequency);
}
}