樓主,[求助] 8051 發(fā)射RC5遙控器源碼!是否可以共享一個(gè)?
我自己寫了下面這一段,沒有辦法實(shí)現(xiàn)呀!
void YKInit() //遙控接收初始化
{
YKDatas[0] = YKDatas[1] = YKDatas[2] = 0;
YKcount = 0;
YKtype = 0;
YKend = 0;
}
void time0() interrupt 1
{
//第一次進(jìn)入中斷前, 定時(shí)1/4位的時(shí)間:445us, 以后則定時(shí)一位時(shí)間1.778ms
//即在3/4位時(shí)間時(shí), 判斷該位是1還是0
//實(shí)際測(cè)試中, 位時(shí)間只在1.651ms(+- 1ms), 定時(shí)1/4位的時(shí)間:413us
bit in = ~YKIn; //一體化解碼后, 有載頻部分變?yōu)榈碗娖? 即低電平實(shí)際為1, 高電平實(shí)際為0
//設(shè)置定時(shí)器初值
//模式1: TH0 = (2^16 - (1651/1.085)) / 2^8 = (65536 - 1651/1.085) / 256 = 250;
//TL0 = (65536 - 1651/1.085) % 256 = 14
TH0 = 250;
TL0 = 14;
YKDatas[YKtype] = YKDatas[YKtype] | in; //將數(shù)據(jù)放入最低位
YKcount++;
if(YKcount == 3) //獲取完Start bits 和control bit, 共3位
{
YKtype = 1;
}
else if(YKcount == 8) //獲取完system bits, 共5位
{
YKtype = 2;
}
else if(YKcount == 14) //獲取完commond bits, 共6位
{
YKtype = 3;
}
else if(YKtype == 3) //等待最后1/4位時(shí)間結(jié)束, 實(shí)際延時(shí)1位時(shí)間
{
YKend = 1;
YKcount = 0;
YKtype = 0;
TR0 = 0; //接收結(jié)束, 停止定時(shí)器0
return;
}
else //將數(shù)據(jù)左移一位, 以便將一下位數(shù)據(jù)并于最低位
{
YKDatas[YKtype] = YKDatas[YKtype] << 1;
}
}
什么函數(shù)呀?是否可以共享?
歡迎光臨 (http://www.torrancerestoration.com/bbs/) | Powered by Discuz! X3.1 |