--------------------------------------------------------------------------------
我用的收音机芯片是CL6017S,它的01h制度寄存器的低10位显示的是频率,它的值和04h低10位的值相等,频率单元是10KHz,初始化后的电台频道是0x15E;我的家台程序是以0.1MHz为单位往上加的,也就是04h寄存器的低10位每次加2。可是当我按键使它增加的时候它却直接跳到了0x60,哪位高手能告诉我这是怎么回事啊?下面是我的调台程序和加台的程序代码
void CL6017S_FMTune(unsigned int TunerFrequency)
{
unsigned int ch = 0;
// frequency transfer to channel number, channel=(frequencyMhz-70)/0.05, e.g. 87.5Mhz->350, 108Mhz->760
ch = (TunerFrequency - 7000)/5;
// set channel number
if(TunerFrequency>100)
CL6017SControlData[1] &= 0xfe;
else
CL6017SControlData[1] |= 0x01
CL6017SControlData[2] &= 0xfc;
CL6017SControlData[2] |= (ch & 0x0300)>>8;
CL6017SControlData[3] = ch & 0xff;
//
// tune function
CL6017SControlData[0] &= 0xdf;// mute off
CL6017SControlData[0] &= 0xfd;// tune=0
I2C_WriteCL6017SReg(CL6017SControlData,4);
CL6017SControlData[0] |= 0x02;//tune=1, begin tune operaton
I2C_WriteCL6017SReg(CL6017SControlData,1);
Delay1Ms(50); // wait for 50ms
}
/**************************************************************************************
* 函数名称:CL6017S_FMSeekFromCurrentCh
* 功 能:
* 输入参数:bool seekUp: 0-seek up, 1-seek down
* 输入参数:unsigned int *TunedFrequency: the radio frequency stay in when seeking process complete, the frequency unit is 10khz
* 输出参数:bool sfflag: 0-Seek successful 1-Seek failure
* 说 明: seek from current channel automaticly,if want to seek from certain channel, use CL6017S_FMTune to certain channel ahead
**************************************************************************************/
bool CL6017S_FMSeekFromCurrentCh(bool seekUp, unsigned int *TunedFrequency)
{
unsigned int ch = 0;
unsigned int loop,loopSt=0;
bool stcflag,bSt;
unsigned int Temp[6];
unsigned int rssi, envelope,fd;
I2C_ReadCL6017SReg(Temp,6);
ch = (Temp[2]&0x03)*256 + Temp[3]&0xff;
if(ch>600) // if freq>100M, Low Injection
CL6017SControlData[1] &= 0xfe;
else
CL6017SControlData[1] |= 0x01;
CL6017SControlData[2] &= 0xfc;
CL6017SControlData[2] |= (ch & 0x0300)>>8;
CL6017SControlData[3] = ch & 0xff;
// seek operation
CL6017SControlData[0] |= 0x20; // mute on
CL6017SControlData[0] &= 0xfd; //tune=0
CL6017SControlData[0] &= 0xfe; //seek=0
I2C_WriteCL6017SReg(CL6017SControlData,2);
CL6017SControlData[0] |= 0x02; //tune=1,
I2C_WriteCL6017SReg(CL6017SControlData,1);
Delay1Ms(45); // delay 50ms
// waiting seek completed
stcflag=0;
loop=0;
rssi = 0;
envelope = 0;
fd = 0;
I2C_ReadCL6017SReg(Temp,6);
stcflag=Temp[0]&0x04; // STC indicator
rssi = Temp[1]&0xff;
envelope = (Temp[2]&0xff)/4;
fd = Temp[5]&0xff;
if(fd>125)
fd = 256 - fd;
if((rssi>178)&&(envelope<=38)&&(fd<=14))
{
bSt = 1;
*TunedFrequency=ch*5+7000;
}
else
{
bSt = 0;
}
loopSt++;
};
CL6017SControlData[0] &= 0xdf;// mute off, audio output
I2C_WriteCL6017SReg(CL6017SControlData,1);
return bSt;
}
void CL6017SFM_Channel_Up_short(void)
{
unsigned int chan,n;
n = P6IN & 0xf8;
if((P6IN & 0xf8) == n)
{
I2C_ReadCL6017SReg(rreg,4);
chan = ((rreg[2] & 0x03)*256 + rreg[3] & 0xff) * 5 + 7000;
if(chan < 10800)
{
chan += 10;
CL6017S_FMTune(chan);
CL6017S_FMSeekFromCurrentCh(0,h);
h++;
if(h == &channel[14])
h = &channel[0];
counter_sw4 = 0;
key_Dat &= ~0x08;
I2C_ReadCL6017SReg(rreg,1);
if(rreg[0] & 0x06)
return;
}
}
}
我是这IC的总代理,联系方式:13662292561,张先生