新聞中心

EEPW首頁 > 嵌入式系統(tǒng) > 設計應用 > 單片機驅動收音機模塊程序

單片機驅動收音機模塊程序

作者: 時間:2016-11-30 來源:網(wǎng)絡 收藏

Convert_PLL();
SendString(RADIO_ADDRESS,radio_write,5);

Display_8x16(0,0,frequency%100000000/10000000);
Display_8x16(8,0,frequency%10000000/1000000);
Display_8x16(16,0,10);
Display_8x16(24,0,frequency%1000000/100000);

/*ReceiveString(RADIO_ADDRESS,radio_read,5);
Display_8x16(0,0,(radio_read[3]&0x80)>>7);
Display_8x16(8,0,(radio_read[3]&0x40)>>6);
Display_8x16(16,0,(radio_read[3]&0x20)>>5);
Display_8x16(24,0,(radio_read[3]&0x10)>>4);*/
for(j=0;j<500;j++)
Display();

while(1)
{
if(ir_value==0x16||ir_value==0x0c||ir_value==0x18||ir_value==0x5e||ir_value==0x08||ir_value==0x1c||ir_value==0x5a||ir_value==0x42||ir_value==0x52||ir_value==0x4a)
{
while(1)
{
if(!i)
{
i=1;
ClearBuf();
//Display_8x16(16,0,10);
}
//if(n==4) frequency*=10;
if(ir_value==0x16)
{ir_value=0xff;Display_8x16(8*n,0,0);if(!n)frequency=0;n++;}
else if(ir_value==0x0c)
{ir_value=0xff;Display_8x16(8*n,0,1);if(!n)frequency=100000000;else if(n==1)frequency+=10000000;else if(n==2) frequency+=1000000;else if(n==3)frequency+=100000;n++;}
else if(ir_value==0x18)
{ir_value=0xff;Display_8x16(8*n,0,2);if(!n)frequency=2*100000000;else if(n==1)frequency+=2*10000000;else if(n==2) frequency+=2*1000000;else if(n==3)frequency+=2*100000;n++;}
else if(ir_value==0x5e)
{ir_value=0xff;Display_8x16(8*n,0,3);if(!n)frequency=3*100000000;else if(n==1)frequency+=3*10000000;else if(n==2) frequency+=3*1000000;else if(n==3)frequency+=3*100000;n++;}
else if(ir_value==0x08)
{ir_value=0xff;Display_8x16(8*n,0,4);if(!n)frequency=4*100000000;else if(n==1)frequency+=4*10000000;else if(n==2) frequency+=4*1000000;else if(n==3)frequency+=4*100000;n++;}
else if(ir_value==0x1c)
{ir_value=0xff;Display_8x16(8*n,0,5);if(!n)frequency=5*100000000;else if(n==1)frequency+=5*10000000;else if(n==2) frequency+=5*1000000;else if(n==3)frequency+=5*100000;n++;}
else if(ir_value==0x5a)
{ir_value=0xff;Display_8x16(8*n,0,6);if(!n)frequency=6*100000000;else if(n==1)frequency+=6*10000000;else if(n==2) frequency+=6*1000000;else if(n==3)frequency+=6*100000;n++;}
else if(ir_value==0x42)
{ir_value=0xff;Display_8x16(8*n,0,7);if(!n)frequency=7*100000000;else if(n==1)frequency+=7*10000000;else if(n==2) frequency+=7*1000000;else if(n==3)frequency+=7*100000;n++;}
else if(ir_value==0x52)
{ir_value=0xff;Display_8x16(8*n,0,8);if(!n)frequency=8*100000000;else if(n==1)frequency+=8*10000000;else if(n==2) frequency+=8*1000000;else if(n==3)frequency+=8*100000;n++;}
else if(ir_value==0x4a)
{ir_value=0xff;Display_8x16(8*n,0,9);if(!n)frequency=9*100000000;else if(n==1)frequency+=9*10000000;else if(n==2) frequency+=9*1000000;else if(n==3)frequency+=9*100000;n++;}
else if(ir_value==0x43)
{ir_value=0xff;Convert_PLL();SendString(RADIO_ADDRESS,radio_write,5);n=0;i=0;break;}
//if(n==2)
//n++;
for(j=0;j<100;j++)
Display();
}
}

else if(ir_value==0x15)
{
ir_value=0xff;//清除
frequency=frequency+100000;
Convert_PLL();
SendString(RADIO_ADDRESS,radio_write,5);
break;
}

else if(ir_value==0x07)
{
ir_value=0xff;
frequency=frequency-100000;
Convert_PLL();
SendString(RADIO_ADDRESS,radio_write,5);
break;
}
else if(ir_value==0x44||ir_value==0x40)//自動搜臺
{
while(1)
{

if(ir_value==0x40)//向上自動搜臺
{frequency+=100000;if(frequency>108000000)frequency=78000000;}
else {frequency-=100000;if(frequency<78000000)frequency=108000000;}
Convert_PLL();
SendString(RADIO_ADDRESS,radio_write,5);

if(frequency>108000000||frequency<78000000)break;

ReceiveString(RADIO_ADDRESS,radio_read,5);
Convert_Frequency();

if(((radio_read[2]&0x7f<0x3E)&(radio_read[2]&0x7f>0x31)|(radio_read[3]>>4)>5|(radio_read[0]&0x80)))
break;
else if(ir_value==0x43){break;}

Display_8x16(0,0,frequency%100000000/10000000);
Display_8x16(8,0,frequency%10000000/1000000);
Display_8x16(16,0,10);
Display_8x16(24,0,frequency%1000000/100000);
Display();
}
ir_value=0xff;
break;
}
else if(ir_value==0x46)//待機or正常
{
if(radio_write[3]&0x40)
radio_write[3]&=0xbf;
elseradio_write[3]|=0x40;
ir_value=0xff;
//i=0;
break;
}
else if(ir_value==0x43||matrix.S==FIRST)
{
ir_value=0xff;
//i=0;
k=0;
//Radio_Init();不待機即可后臺運行
matrix.S=FIRST;
break;
}
}
}

void Radio_Key(void)
{
if(!KEY_ENTER)
{
DelayMs(SCAN_DELAY);
if(!KEY_ENTER)
{
while(!KEY_ENTER)
;
matrix.S=FIRST;
}
}
}

/*
void Radio_Read1()
{
ReceiveString(0xc0,radio_read,5);
Convert_Frequency();

if(radio_read[0]&0x80)
temp[6]=duanma[1];
else temp[6]=duanma[0];


if(radio_read[0]&0x40)
{
temp[7]=duanma[1];
}
else temp[7]=duanma[0];


temp[0]=duanma[frequency/100];
temp[1]=duanma[frequency%100/10];
temp[2]=duanma[frequency%10];

}
*/

#endif


上一頁 1 2 下一頁

關鍵詞: 單片機收音機模

評論


技術專區(qū)

關閉