关天TEA5767收音芯片自动搜台的困惑?
本人用TEA5767收音芯片调试了很久,一直是自动搜台这个地方有问题。送固定的频段都可以收到,但搜台时感觉老锁不住,我是一直不停读芯片数据只要标志位置1就停下来,只能搜到两三个台,我认真看了资料,好像没有什么问题,步进+-225,+-200,+-100,都试过不知哪位大侠能赐教!!非常感谢!!
下面的一个初步调试程序,仅供参考。
#include<reg51.h>
#include<intrins.h>
#include<string.h>
#define uchar unsigned char
#define uint unsigned int
#define LowestFM 87500 //87.5MHz for EUR only for USA 87.9M
#define HighestFM 108000 //108.Mhz
#define InitFM 98000 // 98.00 MHzfor reset Freq
#define STEP 100 //setp size =100KHz.
#define REFERENCE_FREQ32.768
unsigned long SearchFreq; // vco frequency after search command
unsigned long PresetFreq = 89800; // target vco frequency for Preset
unsigned long WorkingFreq; // displayed vco frequency
/*static const uchar tuner_station_data=
{0x2a,0x17,0x2a,0x3c,0x2c,0x61,0x2c,0x86,0x2d,0x56,0x2e,0x00,0x2e,0x5c,
0x2e,0xc4,0x2f,0xac,0x2f,0xf5,0x31,0x4b,0x32,0x0e,0x32,0xf6,0x33,0x33};*/
uchar pingduan_sy={
0x2a,0x17,//88.5MHZ
0x2a,0x3c,//88.8MHZ
0x2c,0x61,//93.3MHZ
0x2c,0x86,//93.6MHZ
0x2d,0x56,//95.3MHZ
0x2e,0x00,//96.7MHZ
0x2e,0x5c,//97.5MHZ
0x2e,0xc4,//98.3MHZ
0x2f,0xac,//100.2MHZ
0x2f,0xf5,//100.8MHZ
0x31,0x4b,//103.6MHZ
0x32,0x0e,//105.2MHZ
0x32,0xf6,//107.1MHZ
0x33,0x33,//107.6MHZ
};
sbit KEY1=P0^0;
sbit SDA=P2^7;
sbit SCL=P2^6;
sbit W_R=P2^4;
sbit ENABLE=P2^5;//
uchar write_data0;
uchar bdata write_data1;
uchar data write_data2;
uchar bdata write_data3;
uchar bdata write_data4;
uchar data write_data5;
sbit MUTE=write_data1^7;
sbit SM=write_data1^6;
sbit SUD=write_data3^7;
sbit SSL1=write_data3^6;
sbit SSL0=write_data3^5;
sbit HLSI=write_data3^4;
sbit MS=write_data3^3;
sbit ML=write_data3^2;
sbit MR=write_data3^1;
sbit SWP1=write_data3^0;
sbit SWP2=write_data4^7;
sbit STBY=write_data4^6;
sbit BL=write_data4^5;
sbit XTAL=write_data4^4;
sbit SMUTE=write_data4^3;
sbit HCC=write_data4^2;
sbit SNC=write_data4^1;
sbit SI=write_data4^0;
uchar bdata read_data1;
uchar data read_data2;
uchar data read_data3;
uchar bdata read_data4;
uchar data read_data5;
sbit RF=read_data1^7;
sbit BLF=read_data1^6;
void key_process()
{
}
voiddelay(uchar n)
{while(--n);}
voiddelay_500us()
{
uchar j;
for(j=0;j<5;j++)
{delay(100);}
}
void send_data(uchar s)
{
uchar i;
for(i=0;i<8;i++)
{
s<<=1;
SDA=CY;
delay(1);
SCL=1;
delay(1);
SCL=0;
delay(1);
}
}
void ack()
{SDA=1;
delay(5);
SCL=1;
//k=200;
while(SDA){};//&&(k--)
SCL=0;
}
void write_page()
{
SDA=1;
SCL=0;
W_R=1;
delay(2);
W_R=0;
delay(2);
W_R=1;
delay(2);
//send_data(write_data0);
send_data(write_data1);
send_data(write_data2);
send_data(write_data3);
send_data(write_data4);
send_data(write_data5);
}
uchar receive_data(void)
{
uchar i=8;
uchar r=0;
do
{
//delay(1);
i--;
r<<=1;
SCL=1;
//CY=SDA;
if(SDA) r|=0x01;
else r&=0xfe;
delay(1);
SCL=0;
}
while(i>0);
delay(1);
return(r);
}
void read_page()
{
SDA=1;
SCL=0;
W_R=0;
delay(1);
W_R=1;
delay(1);
W_R=0;
delay(1);
read_data1=receive_data();
}
void FM5767_UP_SEARCH( void)
{
write_page();
delay(10);
write_data1|=0x40;
write_page();
read_page();
}
main()
{
uint i;
uchar j,temp;
W_R=1;
SCL=0;
ENABLE=1;
read_data1=0x40;
write_data1=0x2e; //2a2a 2e 07DE 6e9f 98M/2E 9F 33 64后一次 2a b6
write_data2=0x9f; //b63c 01
write_data3=0x41; //d0c841c1
write_data4=0x11;
write_data5=0x40;
write_page();
for(i;i<250;i++)
{
delay_500us();
}
/*for(j=0;j<14;j++)
{
write_data1=pingduan_sy;
write_data2=pingduan_sy;
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
_nop_();
}
delay(200);
write_page();
write_data1=0x2a;
write_data2=0x3c;
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x2c;
write_data2=0x61;
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x2c;
write_data2=0x86;
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x2e;
write_data2=0x5c;
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
SearchFreq=LowestFM;
for(j=0;j<200;j++)
{
SearchFreq+=STEP;
i=(unsigned int)((float)((SearchFreq -225)*4)/(float)REFERENCE_FREQ);
temp=i>>8;
write_data1=temp;
temp=i;
write_data2=temp;
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
_nop_();
}
write_data1=0x2d;
write_data2=0x56;
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x2e;//效果不行
write_data2=0x01;
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x2e;
write_data2=0xc4; //不清
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x2f;
write_data2=0xac;
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x2f;
write_data2=0xf5;
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x30;
write_data2=0x63; //不行
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x30;//不行
write_data2=0xa0;
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x31;
write_data2=0x4b;
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x31;
write_data2=0xd1;//不行
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x31;
write_data2=0xea;
write_data3=0x41;//不行
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x32;
write_data2=0x0e;
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x32;
write_data2=0x88;//不行
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x32;
write_data2=0xde;//不行
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x32;
write_data2=0xf6;
write_data3=0x41;
write_data4=0x11;
write_data5=0x40;
write_page();
write_data1=0x29;
write_data2=0x9d;
write_data3=0xe1;//41->61高电平检测第 三 字节最高位高为向上搜台 BIT 6 ,5,为清晰度
write_data4=0x11;
write_data5=0x40;
write_page();*/
write_data1=0x33;
write_data2=0x33;
write_data3=0x61;//41->61高电平检测
write_data4=0x11;
write_data5=0x40;
write_page();
FM5767_UP_SEARCH();
while(1)
{
read_page();
while(!RF)
{
//delay(200);
read_page();//循环检测第一个字节是否有台
};
read_data2=receive_data();
read_data3=receive_data();
read_data4=receive_data();
read_data5=receive_data();
write_data1=read_data1&0x3f;
write_data1|=0x40;
write_data2=read_data2;
write_data2=write_data2-0x0c;//0c 步进100 0x18 步进200 向上搜时为加,向下搜时为减按两种步进搜时可得到更多台
read_data1&=0x7f;/*仿真时在这里设断点*/
write_page();
}
}
//2a 17 88.5MHZ
//2a 3C 88.8MHZ
// 2c61 93.3MHZ
// 2CH 86H 93.6MHZ
// 2DH,56H 95.3MHZ
// DB 2EH,01H /00 ;96.7MHZ //不行
// 2e5c 97.5MHZ
// DB 2EH,0C4H ;98.3MHZ //不行
// DB 2FH,0ACH ;100.2MHZ
// DB 2FH,0F5H ;100.8MHZ
// DB 30H,63H ;101.7MHZ//不行
// DB 30H,0A0H ;102.2MHZ //不行
// DB 31H,4BH ;103.6MHZ
// DB 31H,0D1H ;104.7MHZ //不行
// DB 31H,0EAH ;104.9MHZ //不行
// DB 32H,0EH ;105.2MHZ
// DB 32H,88H ;106.2MHZ//不行
// DB 32H,0DEH ;106.9MHZ//不行
// DB 32H,0F6H ;107.1MHZ
// DB 33H,33H ;107.6MHZ 楼上的,你从哪里找到这颗IC的详细开发资料的?
从网上只有简要的说明。
似乎所有FM数字接收IC的资料都是不公开的。。。。。。 楼主有没有用过LV23002M,我手头有一个用这颗芯片做的收音头,由于没有找到具体的资料,连声音都没有调出来。 我现在也不记得了,好像也是网上找的,如果要我可以传上来,LV23002M没用过,我本来是要调好之后,改成AVR CPU后用到音响上面去的,现在看来要推迟时间了,本来项目就急,其它都做得差不多了就剩下一个收音头,还花了我很多时间,真烦,涨工资也要推迟了。 本来就没有几个人愿意去读别人的程序来找错,
而且,大多数人从google找到的,都只是一份介绍性的文章,也不可能知道如何使用它。
所以,估计这个帖子无人应答。 哈哈 自动搜索的小广播早在8年前就在地摊上销售了啊,10元一只的那种,嘿嘿 首先声明这个程序是经过我验证的,我现在正在使用这段程序,我用的是AVR M16 单片机,参考一下这个程序,这个程序是可以自动搜索的
/*
****************************************************************************
Copyright 2001 Philips Semiconductors Limited,
35/F,Panglin Plaza, No. 2002,Jia BIn Road,Luo Hu District,Shenzhen 518001, PRC.
All rights are reserved. Reproduction in whole or in part is prohibited
without the prior written consent of the copyright owner.
COMPANY CONFIDENTIAL
***************************************************************************
Filename : Tuner.c
Rev Date Author
____________________________________________________________________________
1.0 2002/01/13 Tenon Mao
TEA5767 basic control
*/
#define XTAL32K
#define LowestFM 87500 //87.5MHz for EUR only for USA 87.9M
#define HighestFM 108000 //108.Mhz
#define InitVCO 98000 // 98.00 MHzfor reset Freq
#define STEP 100 //setp size =100KHz.
#define AST_STEP 200 //200
#define MAX_STATION 20
#define TUNER_DELAY 250000 //250MS
#ifdef XTAL32K
#define REFERENCE_FREQ 32.768
#else
#define REFERENCE_FREQ 50.000
#endif
/**********************
* INCLUDE FILES *
**********************/
/* Standard include files */
/* Projectinclude files */
#include "global.h"
#include "tuner.h"
#include "util.h"
#include "lcd.h"
#include "key.h"
/**********************
* LOCAL TYPEDEFS *
**********************/
/**********************
* EXPORTED DATA *
**********************/
BYTEdata SearchLevel=3;
BYTE idata WriteDataWord; // write tea5767H dataword
BYTE idata ReadDataWord; // read tea5767H dataword
unsigned long idata TunerStation; //save radio station FM Value HEX format
///For assembly data
BIT data FlagMute = False; // flag to Mute R&L
BIT data FlagSearch = False; // flag to search or preset mode
BIT data FlagSearchtUp =True; // flag for search direction
BYTE data FlagLevel =2; // flag for current search level
BIT data FlagHighInjection=False;
BIT data FlagMono = False; // flag to force mono
//Mute L
//Mute R
//SWPORT1 for GPIO out
BIT data FlagSWPORT2=Low; // flag for level of pin15
//standy_by
//Japan or ther area
//XTAL selecton 1 for 32k
BIT data FlagSoftMute = True;//False; // flag to force mono
//HCC
//SNC
BIT data FlagSWPORT1=True; // 1= confige as indication of found!!
//PLL selection 0
//Deem 1.
BYTE data NowStation=0;
BYTE data Max_Station=0;
unsigned long gdwSearchedVCO; // vco frequency after search command
unsigned long gdwPresetVCO=89800; // target vco frequency for Preset
unsigned long gdwWorkingVCO; // displayed vco frequency
BIT data NotFound = True;
BIT data BandLimit = False; // Indicate the end of band
//unsigned char TunerSearchTimer; //Timeout for serach
/**********************
* STATIC DATA *
**********************/
/**********************
* LOCAL MACROS *
**********************/
/**********************
* FUNCTION PROTOTYPES *
**********************/
/****************************************************************************/
/* Command Delay */
/****************************************************************************/
void CMD_Delay(BYTE i)
{
for (; i!=0; i--) ;
}
void CMD_CheckHighSCL()
{
I2cSCL = 1;
}
void CMD_SendStart()
{
I2cSCL = 1;
CMD_Delay(CMD_DELAY);
I2cSDA = 0;
CMD_Delay(CMD_DELAY);
I2cSCL = 0;
CMD_Delay(CMD_DELAY);
}
void CMD_SendStop()
{
I2cSDA = 0;
CMD_CheckHighSCL();
CMD_Delay(CMD_DELAY);
I2cSDA = 1;
CMD_Delay(CMD_DELAY);
}
BYTECMD_SendByte(BYTE bByte)
{
BYTE i;
BITAcknowledge=1;
for(i=0;i<8;i++)
{
if(bByte&0x80)
I2cSDA=1;
else
I2cSDA=0;
bByte<<=1;
CMD_Delay(CMD_DELAY);
CMD_CheckHighSCL();
I2cSCL=0;
}
I2cSDA=1;
I2cSCL=1;
CMD_Delay(CMD_DELAY);
if (I2cSDA) Acknowledge=0;
I2cSCL=0;
CMD_Delay(CMD_DELAY);
return Acknowledge;
}
BYTE CMD_GetByte(BYTE Acknowledge)
{
BYTE i,bByte=0, bMask=0x80;
for(i=0;i<8;i++)
{
CMD_Delay(CMD_DELAY);
I2cSCL=1;
if(I2cSDA)bByte|=bMask;
bMask >>= 1;
I2cSCL=0;
}
I2cSDA =(Acknowledge)?1:0;
CMD_CheckHighSCL();
CMD_Delay(CMD_DELAY);
I2cSCL=0;
I2cSDA=1;
CMD_Delay(CMD_DELAY);
return bByte;
}
//////////////////////////////////////////////
void WriteSTR()
{
BYTE i;
EA=0;
CMD_SendStart();
if (CMD_SendByte(0x0c0)) //chip addr of write data to driver
{
for (i=0; i<5; i++)
{
if (!CMD_SendByte(WriteDataWord)) //0 err
{
break;
}
}
}
CMD_SendStop(); //???
EA=1;
CMD_Delay(CMD_DELAY);
CMD_Delay(CMD_DELAY);
}
Byte SearchRead1=0; //for test only!!!
Byte SearchRead2=0;
Byte SearchRead3=0;
Byte SearchRead4=0;
Byte SearchRead5=0;
void ReadSTR() //get datd../
{
BYTE i;
#if 1 //test only!!
for (i=0; i<=4; i++)
{
ReadDataWord=0; //init the read buffer.
}
SearchRead1=ReadDataWord; //byte 0 --4 .byte 0 first.
SearchRead2=ReadDataWord; //byte 0 --4 .byte 0 first.
SearchRead3=ReadDataWord; //byte 0 --4 .byte 0 first.
SearchRead4=ReadDataWord; //byte 0 --4 .byte 0 first.
SearchRead5=ReadDataWord; //byte 0 --4 .byte 0 first.
Delay10us(2);
#endif
CMD_SendStart();
if (CMD_SendByte(0x0c1)) //chip addr of read data
{
for (i=0;i<5;i++)
ReadDataWord =(i==4)? CMD_GetByte(1):CMD_GetByte(0); //the last byte with ACK.
CMD_SendStop();
}
else CMD_SendStop();
#if 1 //test only!!
SearchRead1=ReadDataWord; //byte 0 --4 .byte 0 first.
SearchRead2=ReadDataWord; //byte 0 --4 .byte 0 first.
SearchRead3=ReadDataWord; //byte 0 --4 .byte 0 first.
SearchRead4=ReadDataWord; //byte 0 --4 .byte 0 first.
SearchRead5=ReadDataWord; //byte 0 --4 .byte 0 first.
Delay10us(2);
#endif
}
/////////////////////////
/*********************************************************
* NAME : SearchOver
* CHK if thesearch Finished accoding the SWPORT1
*
* Returns : none
*
* Parameter Description
* --------------------------------------------------------
* none
*
* Externals Usage
* --------------------------------------------------------
*
*
* Additional information:
* Local subfunction
*********************************************************/
BYTE dataLowCount=0; //for test only
static BIT SearchOver(void)
{
LowCount++;
return(SWPORT1) ; //PIN from low to high. Then tuning over
}
/*********************************************************
* NAME : TuneOver
* CHK if the PreeSet or search Finished according
* the read byte1.7
*
*
* Returns : none
*
* Parameter Description
* --------------------------------------------------------
* none
*
* Externals Usage
* --------------------------------------------------------
*
*
* Additional information:
* Local subfunction
*********************************************************/
BYTE tbRead1;
BYTE tbRead2;
BIT Stereo=False;
BIT Ready=False;
static void TuneOver(void)
{
BIT Ready=False;
ReadSTR(); //how about continue read???? mao 0227
tbRead1=ReadDataWord;
tbRead2=ReadDataWord;
LowCount++; //for test only.
if((tbRead1&0x40) != 0) BandLimit=True; //limited
else BandLimit=False;
if((tbRead2&0x80) != 0) Stereo=True;
else Stereo=False;
tbRead1=ReadDataWord;
if((tbRead1&0x80) != 0) Ready=True; //Found
else Ready=False;
}
/*********************************************************
* NAME : AssembleFrequencyWord
* given a VCO frequency calculate and load the frequency databitsr
* and save the PLL Fre to DataWord =14 bits
* 5757 have 15 bits and the bits location is different!
* Returns : none
*
* Parameter Description
* --------------------------------------------------------
* none
*
* Externals Usage
* --------------------------------------------------------
*WriteDataWord the bits will be Set according cal result(out)
*gdwPresetVCO in
*
* Additional information:
* Local subfunction
* All the Frequency unit is KHz.!
* Test it is ok 02/26
*********************************************************/
static void AssembleFrequencyWord(void)
{
UINT16 twPLL =0; //Dec
UINT32 tdwPresetVCO=gdwPresetVCO; //Khz
BYTE tbTmp1;
BYTE tbTmp2;
// calcu1ate frequency dataword bits from given station frequency BCD:
if(FlagHighInjection)
twPLL =(unsigned int)((float)((tdwPresetVCO +225)*4)/(float)REFERENCE_FREQ);
else
twPLL =(unsigned int)((float)((tdwPresetVCO -225)*4)/(float)REFERENCE_FREQ);
//convert BCD to Hex.
tbTmp1 =(unsigned char)(twPLL%256); //6789=Hex1A85 -->133=Hex85
tbTmp2 =(unsigned char)(twPLL/256); // -->26=Hex1A
WriteDataWord=tbTmp2; //high block
WriteDataWord=tbTmp1;
}
/*********************************************************
* NAME : DisAssembleFrequencyWord
* given a frequency dataword and waveband,
* calculate the VCO frequency
* Get the PLL Freq BITs from DataWord =14 bits
* 5757 have 15 bits and the bits location is different!
* Returns : none
*
* Parameter Description
* --------------------------------------------------------
* none
*
* Externals Usage
* --------------------------------------------------------
* ReadDataWord the bits will be taken(in)
* gdwSearchedVCO the Freq (out)
*
* Additional information:
* Local subfunction
* Tested, It is Ok. 02/26
*********************************************************/
void DisAssembleFrequencyWord(void)
{
UINT16 twPLL =0; //Dec
UINT32 tdwPresetVCO=gdwPresetVCO; //Khz
BYTE tbTmp1=ReadDataWord;
BYTE tbTmp2=ReadDataWord;
tbTmp2&=0x3f;
twPLL=tbTmp2*256+tbTmp1;
// calculate searched station frequency from dataword bits
if(FlagHighInjection)
gdwSearchedVCO =(unsigned long)((float)twPLL*(float)REFERENCE_FREQ*(float)0.25-225);
else
gdwSearchedVCO =(unsigned long)((float)twPLL*(float)REFERENCE_FREQ*(float)0.25+225);
}
/*********************************************************
* NAME : AssembleData
* assemble a full data word based on global variables
*
* Returns : none
*
* Parameter Description
* --------------------------------------------------------
* none
*
* Externals Usage
* --------------------------------------------------------
* DataWord the bits will be Set(out)
* The global Variable in as below list!!
*
* FlagSearch in, if search or preSet mode?StartSearch
* FlagLevel insearch stop level
* FalgMono in.
* FlagSWPORT2 in
* FlagSearchtUp in
* gdwPresetVCO in
*
* WriteDataWord[] out.
*
* Additional information:
* Local subfunction
* Tested, It is Ok. 4/16
*********************************************************/
BYTE Write1;
static void AssembleData(void)
{
WriteDataWord = 0x11; //32k /p1 found.
WriteDataWord = 0x40;
if(FlagMute) WriteDataWord |= 0x80;
elseWriteDataWord &= 0x7f ; //0111 1111
if (FlagSearch ) // search mode
{
WriteDataWord |= 0x40; // Set to 1 for search start; other =0.
// Set the bits of BYTE3 of search
if(FlagSearchtUp) WriteDataWord |= 0x80;
elseWriteDataWord &= 0x7f; //0111 1111
if ((FlagLevel & 0x02) == 0x02) WriteDataWord |=0x40 ;
else WriteDataWord &=0x0bf; //1011 1111
if ((FlagLevel & 0x01) == 0x01) WriteDataWord |=0x20;
else WriteDataWord &=0x0df; //1101 1111
Write1= WriteDataWord ;
}
/////PreSet mode
else
{
AssembleFrequencyWord();
WriteDataWord &= 0x0bf; // Set to 0 for Preset mode. 1011,1111
}
//set the public data bit of BYTE3
if(FlagHighInjection) WriteDataWord |= 0x10 ;
elseWriteDataWord &= 0x0ef; //1110 1111
if(FlagMono) WriteDataWord |= 0x08 ;
elseWriteDataWord &= 0x0f7 ; //1111 0111
//set the public data bit of BYTE4
if(FlagSWPORT2) WriteDataWord |= 0x80;
elseWriteDataWord &= 0x7f ; //0111 1111
if(FlagSoftMute) WriteDataWord |= 0x08;
elseWriteDataWord &= 0xf7 ; //1111 0111
if(FlagSWPORT1) WriteDataWord |= 0x01;
elseWriteDataWord &= 0xfe ; //1111 1110
}
//////////////////////////////////////////////////////////////////////////////////
/* Above are local sub routine and called in this file */
/*********************************************************
* NAME : Tuner_Preset
* PreSet the 5767 to a Staion_FREQ
*
* Returns : none
*
* Parameter Description
* --------------------------------------------------------
* none
*
* Externals Usage
* --------------------------------------------------------
* Target VCO in
*
* Additional information:
* Local subfunction
* Tested, It is Ok. 4/16
*********************************************************/
void Tuner_Preset (BIT Mute, BIT SetMono,BIT Pin15,unsigned long VCO)
{
FlagSearch = False; // Set global parameters
FlagMono = SetMono;
FlagSWPORT2 = Pin15;
gdwPresetVCO = VCO;
FlagMute=Mute; //0301 mao
AssembleData();
WriteSTR();
Delay10us(50000); //200ms
ReadSTR(); //read data to ReadDataWord[] .
Delay10us(2);
#if 0
// while (SWPORT1);
while(!SearchOver() ) // waiting for station detected
{
Delay10us(2000);
WriteSTR();
}
#endif
}
/*********************************************************
* NAME : Tuner_Search
* Tea5767 to search a statioon.
*
* Returns : none
*
* Parameter Description
* --------------------------------------------------------
* none
*
* Externals Usage
* --------------------------------------------------------
* DataWord the bits will be taken(in)
* gdwSearchedVCO the Freq (out)
*
* Additional information:
* Local subfunction
*********************************************************/
void Tuner_Search (BIT Direction,BYTE Level ) // target level to search for
{
if (Direction)
{
Tuner_Preset (False,False,Low,gdwPresetVCO+AST_STEP); // Preset to searched station 0301 mao
FlagHighInjection=False;
}
else
{
Tuner_Preset (False,False,Low,gdwPresetVCO-AST_STEP);
FlagHighInjection=True;
}
FlagSearch = True; // Set global parameters
FlagSearchtUp = Direction;
FlagLevel = Level;
FlagMute=True; //0301 mao
AssembleData();
WriteSTR();
// Delay10us(100000); //1s ms
///////////////////
#if 1
while (SWPORT1);
Delay10us(2);
while(!SearchOver() ) // waiting for station detected
{
NotFound = True;
}
FlagSearch = False; //Reset search flag
ReadSTR(); //read data to ReadDataWord[] .
Delay10us(2); //for test only
DisAssembleFrequencyWord(); // retrieve VCO frequency from ReadDataWord[]
Delay10us(2);
#else
/////////////////////////
do
{
Delay10us(10000); //0.1s ms
ReadSTR(); //how about continue read???? mao 0227
tbRead1=ReadDataWord;
tbRead2=ReadDataWord;
LowCount++; //for test only.
Delay10us(20);
if((tbRead1&0x80) != 0) Ready=True; //Found
else Ready=False;
Delay10us(20);
if((tbRead1&0x40) != 0) BandLimit=True; //limited
else BandLimit=False;
Delay10us(20);
if((tbRead2&0x80) != 0) Stereo=True;
else Stereo=False;
Delay10us(20);
if(Ready) break;
DisAssembleFrequencyWord(); // retrieve VCO frequency from ReadDataWord[]
Tuner_Preset (True,False,Low,gdwPresetVCO); // Preset to searched station 0301 mao
FlagSearch = True; // Set global parameters
AssembleData();
WriteSTR();
Delay10us(20000); //for test only
} while( !BandLimit ) ;
DisAssembleFrequencyWord(); // retrieve VCO frequency from ReadDataWord[]
#endif
///////////////////////////////
FlagSearch = False; //Reset search flag
if ( (gdwSearchedVCO > HighestFM )|| (gdwSearchedVCO < LowestFM ) )
{
BandLimit=True;
FlagSWPORT2=True;
LCD_ShowChar(LCD_ERR);
}
else
{
Tuner_Preset (False,False,Low,gdwSearchedVCO); // Preset to searched station 0301 mao
LCD_ShowFM(0x00,gdwSearchedVCO);
BandLimit=False;
}
Delay10us(20); //for test only
LowCount=0;
}
/*********************************************************
* NAME : Tuner_AST_Search
* Perform the AST function
*
* Returns : none
*
* Parameter Description
* --------------------------------------------------------
* none
*
* Externals Usage
* --------------------------------------------------------
*
* Additional information:
* To simplify the control,we only search one level of 3.
* in factly we should search 2 and 3 level.
*
*********************************************************/
BYTE station_num=0;
void Tuner_AST_Search(void)
{
UINT32 InitASTVCO=0;
//Mute(ON); //no sound out
//clear the sation buffer!!!
for(station_num=0;station_num<=MAX_STATION;station_num++)
{
TunerStation=0;
}
station_num=0;
gdwPresetVCO = LowestFM-AST_STEP; // Lowest -SETP
Delay10us(20); // Test only
do
{
//Tuner_Preset (False,False,Low,gdwSearchedVCO+AST_STEP );
//Delay10us(50000); // 500ms delay
Tuner_Search(Up,SearchLevel);
if(!BandLimit)
{
Delay10us(2); // Test only
station_num++; //stion 0 not used.
TunerStation=gdwSearchedVCO;
gdwPresetVCO =gdwSearchedVCO; //for next search use
//Tuner_Preset (False,False,Low,gdwSearchedVCO); //???? 0308 for test????
// LCD_ShowFM(station_num,gdwSearchedVCO);
Delay10us(100000); // 1s delay
}
else
{
SearchLevel--;
BandLimit=False;
break;
}
Delay10us(2); // 250ms delay
}while(station_num < MAX_STATION+1);
Max_Station=station_num;
////////////////////////////////////
if(Max_Station >0) //if found station!!!
{
Delay10us(100);
/* when exit AST, preset a fm station */
NowStation=1;
gdwWorkingVCO=TunerStation;
Tuner_Preset (False,False,Low,gdwWorkingVCO);
//Mute(OFF); //sound out
// LCD_ShowFM(NowStation,gdwWorkingVCO);
}
else
LCD_ShowChar(LCD_ERR);
}
/*********************************************************
* NAME : Tuner_Init
* Tea5767 init. and preset it to a station.
*
* Returns : none
*
* Parameter Description
* --------------------------------------------------------
* none
*
* Externals Usage
* --------------------------------------------------------
* DataWord the bits will be taken(in)
* gdwSearchedVCO the Freq (out)
*
* Additional information:
* Local subfunction
*********************************************************/
void Tuner_Init(void)
{
BYTE i;
for(i=0;i<5;i++) //Clear 5767 data buffer =0
{
ReadDataWord = False;
WriteDataWord =False;
}
WriteDataWord = 0x2a; // init FM89.8MHz ok.
WriteDataWord = 0x0b6;
WriteDataWord = 0x41;
WriteDataWord = 0x11; //soft Mute
WriteDataWord = 0x40;
WriteSTR();
Delay10us(100);
WriteDataWord = 0x2a; // init FM89.8MHz ok.
WriteDataWord = 0x0b6;
WriteDataWord = 0x41; //p1 high
WriteDataWord = 0x11;
WriteDataWord = 0x40;
WriteSTR();
Tuner_Preset( False, False,High,97100 );
}
/*********************************************************
* NAME : Tuner_UIF
* According the key val to process the function!!
*
* Returns : none
*
* Parameter Description
* --------------------------------------------------------
* none
*
* Externals Usage
* --------------------------------------------------------
*
*
* Additional information:
* none
*********************************************************/
void Tuner_UIF(void)
{
if( gbNewKey != KEY_NONE )
{
//ClearDisplayDelay(); // clear display delay timer
Delay10us(8);
switch( gbNewKey )
{
caseKEY_PREV_DIR: //25 Prev station103.2
Tuner_Search (Down,SearchLevel );
Tuner_Preset (False,False,Low,gdwSearchedVCO); // Preset to searched station 0301 mao
break;
case KEY_NEXT_DIR: //next staion 103.2
Tuner_Search (Up,SearchLevel );
Tuner_Preset (False,False,Low,gdwSearchedVCO); // Preset to searched station 0301 mao
break;
caseKEY_VOL_DOWN: //Tune down one step 100kHz
Tuner_Preset(False,False,High,gdwPresetVCO-STEP);
break;
case KEY_VOL_UP: //Tune up one step 100kHz
Tuner_Preset(False,False,High,gdwPresetVCO+STEP);
break;
case KEY_FR: //29H
Tuner_Preset(False,False,High,88300); //97100);
break;
case KEY_FF: //2aH
Tuner_Preset(False,False,High,100000); //89800);
break;
case KEY_SOUND_EFFECT: // prev station
Tuner_Preset(False,False,High,97100);
break;
case KEY_ESP: //Next station
Tuner_AST_Search(); //AST FUNCTION
break;
case KEY_PLAY: //
if( NowStation>0)
{
NowStation--;
gdwWorkingVCO=TunerStation;
Tuner_Preset (False,False,Low,gdwWorkingVCO);
}
break;
case KEY_STOP: // 46
if(NowStation<MAX_STATION)
{
NowStation++;
gdwWorkingVCO=TunerStation;
Tuner_Preset (False,False,Low,gdwWorkingVCO);
}
break;
}
gbNewKey = KEY_NONE;
}
}
-----此内容被_yu-ming于2006-10-09,09:09:55编辑过 头文件如下:
/*
****************************************************************************
Copyright 2001 Philips Semiconductors Limited,
35/F,Panglin Plaza, No. 2002,Jia BIn Road,Luo Hu District,Shenzhen 518001, PRC.
All rights are reserved. Reproduction in whole or in part is prohibited
without the prior written consent of the copyright owner.
COMPANY CONFIDENTIAL
***************************************************************************
Filename : tuner.h
Rev Date Author
____________________________________________________________________________
1.0 2002/01/13 Tenon Mao
Header file for tuner.c
*/
#ifndef __TUNER_H
#define __TUNER_H
/**********************
* INCLUDE FILES *
**********************/
/* Standard include files */
/* Projectinclude files */
/**********************
* CONSTANTS *
**********************/
#define CMD_DELAY 10 // set tuner delay cycle
/**********************
* MACROS *
**********************/
/**********************
* FUNCTION PROTOTYPES *
**********************/
//Expoted FUNCTION
void Tuner_Init(void); // initialize tuner
void Tuner_Preset (BIT Mute, BIT SetMono,BIT Pin15,unsigned long VCO);
void Tuner_Search ( BITDirection, BYTELevel);
void Tuner_AST_Search(void);
//LOCAL FUNCTION
BYTE CMD_SendByte(BYTE);
BYTE CMD_GetByte(BYTE);
void ReadSTR( void);
void WriteTR( void);
void DisAssembleFrequencyWord(void);
void Tuner_UIF(void);
#endif 楼上的先谢了,我COPY下来看看
to mig29 笨笨兔我有说要别人看我的程序错误吗?我只是问一下人家的经验。 其实在做TEA5767程序时参靠无锡硅动力微电子技术有限公司的SP3767中文资料就差不多了。
点击此处下载armok01131457.rar TEA5767基本一样的SP3767
想问问各位大侠
TEA5767它的天线应该是什么样子的啊?
怎么弄啊? 一般MP3等是用耳机的公共断作为天线的用电感隔离如下图
http://cache.amobbs.com/bbs_upload782111/files_6/armok01136918.JPG 那里能买到收音芯片呢?想买一片玩玩。那位能提高信息啊? 我就有 这个不贵
就10元一个模块 to:hellokilly
你的模块是什么型号的? jiushiJIU就是 TEA5767HN40个脚的那种~~ 大家可否分享一下实现硬件电路啊~~ 【5楼】 AVR-MEGA128 安步当车
哈哈 自动搜索的小广播早在8年前就在地摊上销售了啊,10元一只的那种,嘿嘿
========================================================================
这种芯片只能自动搜台,不能获取当前频率,且只有单声道. 请问楼主后来问题解决了没有 Wind_Chan 发表于 2006-12-1 13:04
一般MP3等是用耳机的公共断作为天线的用电感隔离如下图
mark,mark。
页:
[1]