⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 5767.txt

📁 keil c 编写的tea5767HL 的程序代码
💻 TXT
📖 第 1 页 / 共 2 页
字号:
  if(FlagMute) WriteDataWord[0] |= 0x80;    
  else  WriteDataWord[0] &= 0x7f    ;                        //0111 1111

  if (FlagSearch )                             // search mode    
        
  {                              
    WriteDataWord[0] |= 0x40;               // Set to 1 for search start; other =0.

    // Set the bits of BYTE3 of search 
    if(FlagSearchtUp) WriteDataWord[2] |= 0x80;                        
    else  WriteDataWord[2] &= 0x7f;                            
        //0111 1111

      if ((FlagLevel & 0x02) == 0x02)    WriteDataWord[2] |=0x40 ;    
       else WriteDataWord[2] &=0x0bf;                            
        //1011 1111    
    
       if ((FlagLevel & 0x01) == 0x01)    WriteDataWord[2] |=0x20;    
       else WriteDataWord[2] &=0x0df;                            
        //1101 1111     
      Write1= WriteDataWord[0]   ;

   
  }
  /////PreSet mode
  else
  {     
      AssembleFrequencyWord();              
         WriteDataWord[0] &= 0x0bf;            // Set to 0 for Preset mode. 1011,1111
  }
 //set the public data bit of BYTE3 
    if(FlagHighInjection)   WriteDataWord[2] |= 0x10 ;                
       else  WriteDataWord[2] &= 0x0ef;                    
    //1110 1111

     if(FlagMono) WriteDataWord[2] |= 0x08    ;
    else  WriteDataWord[2] &= 0x0f7    ;                        //1111 0111

 //set the public data bit of BYTE4 
    if(FlagSWPORT2) WriteDataWord[3] |= 0x80;    
    else  WriteDataWord[3] &= 0x7f    ;                        //0111 1111

    if(FlagSoftMute) WriteDataWord[3] |= 0x08;    
    else  WriteDataWord[3] &= 0xf7    ;                        //1111 0111

    if(FlagSWPORT1) WriteDataWord[3] |= 0x01;    
    else  WriteDataWord[3] &= 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[37-24]     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[0];
 tbRead2=ReadDataWord[2];
 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[station_num]=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[station_num]=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[NowStation];
    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[37-24]     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[i] = False;
   WriteDataWord[i] =False;
  }
 
  WriteDataWord[0] = 0x2a;                // init FM89.8MHz ok.
  WriteDataWord[1] = 0x0b6;
  WriteDataWord[2] = 0x41;            
  WriteDataWord[3] = 0x11;                //soft Mute
  WriteDataWord[4] = 0x40;
  WriteSTR();
  Delay10us(100); 
 
  WriteDataWord[0] = 0x2a;                // init FM89.8MHz ok.
  WriteDataWord[1] = 0x0b6;
  WriteDataWord[2] = 0x41;                 //p1 high        
  WriteDataWord[3] = 0x11;            
  WriteDataWord[4] = 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 )
    {    
                   
        case  KEY_PREV_DIR:            //25 Prev station  103.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;           

        case  KEY_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[NowStation];
           Tuner_Preset (False,False,Low,gdwWorkingVCO);     
           }

            break;

         case KEY_STOP:                    //    46
            if(NowStation<MAX_STATION)
            {
            NowStation++;
            gdwWorkingVCO=TunerStation[NowStation];
            Tuner_Preset (False,False,Low,gdwWorkingVCO);     
            }
            break;
 
    }
    gbNewKey = KEY_NONE;
 }
}相关帖子>>>:把你的硬件描述一下,大家讨论讨论(0字)退而结网[8次]2006-1-16 12:50:37我的硬件描述(506字)调频爱好者[41次]2006-1-16 12:58:07采用TEA5767模组,10脚是ANT   8脚R-OUT   7脚L- OUT  9脚MPX(解调测试),6脚GND
5脚VCC  4脚W/R(3脚接0不用,三线控制用)   3脚BUS MOD(实际接0为IIC)     2 CLOCK    1DATE

我是采用的IIC控制

你是消费电子 电视用的吧!都是IIC控制的(0字)day_new[8次]2006-1-16 14:02:37是消费电子,不用在电视上,在其他语音上的,是IIC,就是不明白14PLL怎么算频率(0字)调频爱好者[8次]2006-1-16 14:26:50I2C总线(0字)wqs19840312[11次]2006-1-16 12:57:50高手啊,刚学就这么牛了(102字)playpolo[3次]2006-1-16 14:07:42*系统信息:晓奇于2006-1-16 20:09:39修改帖子类型为: 垃圾箱
   
 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -