I made a TEA5767 digital FM stereo radio using a perfboard

Publisher:JFETLatest update time:2015-05-11 Source: 51heiKeywords:TEA5767 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere


//This program uses digital tube to display frequency, crystal oscillator is 12M, has passed the test, has been made into finished product with universal board,
//There are photos made with universal board in my QQ space, high-definition photos can be viewed in QQ album, my space is not encrypted.
//In order to facilitate electronic enthusiasts to make their own, this program has macro definitions for all ports, which is convenient for beginners to modify by themselves, and adds a lot of comments
//Written by Mr. Chen Yongfei on February 19, 2011, QQ: 49204743, email: baiyni888@163.com .
//Address: Caochangmen Branch of Suning Appliance After-sales Service Center, No. 180 Huju Road, Gulou District, Nanjing City, Jiangsu Province
//The frequency adjustment of this radio is calculated by calculation. The displayed frequency is calculated and written into the TEA5767 chip to realize the adjustment
//Use MCS-51 single-chip microcomputer for control, two buttons to realize self-increase or self-decrease frequency, and add continuous addition and subtraction function!
//I used a simplified version of the TEA5767 module bought on Taobao for 4.5 yuan per piece. I received ten radio stations in Nanjing.

#include
#include
#include
#define uchar unsigned char
#define uint unsigned int

///
...


​led3=P2^6; //Frequency display digital tube bit selection port 1M, P2.6 port /////port
sbit led4=P2^7; //Frequency display digital tube bit selection port 0.1M, P2.7 port /////,        
sbit SDA=P3^0; //Connected to the data port of TEA5767 /////can
sbit SCL=P3^1; //Connected to the clock port of TEA5767 /////with 
sbit KEY1=P1^0; //Frequency increase button port /////self
sbit KEY2=P1^1; //Frequency decrease button port /////line
#define duan P0 //Frequency display digital tube segment selection P0 port /////
Revise

//unsigned char radio_write_data[5]={0x33,0x8e,0x70,0x16,0x80}; //Data to be written into TEA5767, 107.9M Jiangsu Tourism Station
//unsigned char radio_write_data[5]={0x32,0x8e,0x70,0x16,0x80}; //Data to be written into TEA5767, 105.8M Nanjing Music Station
//unsigned char radio_write_data[5]={0x31,0xd7,0x70,0x16,0x80}; //Data to be written into TEA5767, 104.3M Nanjing Sports Station
//unsigned char radio_write_data[5]={0x30,0x9a,0x70,0x16,0x80}; //Data to be written into TEA5767, 101.7M Nanjing Economic Station City FM
unsigned char radio_write_data[5]={0x30,0x50,0x70,0x16,0x80}; //Data to be written into TEA5767, 101.1M Jiangsu Traffic Radio Network
//unsigned char radio_write_data[5]={0x2f,0xa5,0x70,0x16,0x80}; //Data to be written into TEA5767, 99.7M Jiangsu Golden Color FM
//unsigned char radio_write_data[5]={0x2c,0xc9,0x70,0x16,0x80}; //Data to be written into TEA5767, 97.5M Jiangsu Literature and Art Station
//unsigned char radio_write_data[5]={0x2c,0xc9,0x70,0x16,0x80}; //Data to be written into TEA5767, 93.7M Jiangsu Economic Station Home Broadcast
//unsigned char radio_write_data[5]={0x2b,0xb0,0x70,0x16,0x80}; //Data to be written into TEA5767, 91.4M Jiangsu Broadcast
//unsigned char radio_write_data[5]={0x2a,0xe1,0x70,0x16,0x80}; //Data to be written into TEA5767, 89.7M Jiangsu Music Station


unsigned long frequency=101100; //The radio frequency initialized at power on is 101.1MHz
unsigned int pll; //Variable used to calculate frequency synthesis

 

 

void Delayus(unsigned char x)
{
 for(;x>0;x--);
}

void iic_start()
{
 SDA=1;
 Delayus(4);
 SCL=1;
 Delayus(4);
 SDA=0;
 Delayus(4);
 SCL=0;
 Delayus(4);
}

void iic_stop()
{
 SCL=0;
 Delayus(4);
 SDA=0;
 Delayus(4);
 SCL=1;
 Delayus(4);
 SDA=1;
 Delayus(4);
}

void iic_ack()
{
 SDA=0;
 Delayus(4);
 SCL=1;
 Delayus(4);
 SCL=0;
 Delayus(4);
 SDA=1;
 Delayus(4);
}


bit iic_testack()
{
 bit ErrorBit;
 SDA=1;
 Delayus(4);
 SCL=1;
 Delayus(4);
 ErrorBit=SDA;
 Delayus(4);
 SCL=0;
 return ErrorBit;
}

void iic_write8bit(unsigned char input)
{
 unsigned char temp;
 for(temp=8;temp>0;temp--)
 {
  SDA=(bit)(input&0x80);
  Delayus(4);
  SCL=1;
  Delayus(4);
  SCL=0;
  Delayus(4);
  input=input<<1;
 }
}

[page]
void delays (unsigned char b) //Delay program for key debounce
{
  unsigned char i;
  for(b;b>0;b--)
  for(i=0;i<250;i++);
}

void radio_write(void)
{
    unsigned char i;
    iic_start();
    iic_write8bit(0xc0); //TEA5767 write address
    if(!iic_testack())
    {
        for(i=0;i<5;i++)
        {
            iic_write8bit(radio_write_data[i ]);
            iic_ack();
        }
    }
    iic_stop();   
}


 //Calculate the displayed frequency and write it to the TEA5767 chip for adjustment. Don't consider the related bits used by TEA5767 for searching channels: SM, SUD
void search()
{       
    pll=(unsigned int)((float)((frequency+225))/(float)8.192); //Calculate the synthesized frequency data, frequency unit: k
    radio_write_data[0]=pll/256; //Write the calculated high-order frequency data into TEA5767
    radio_write_data[1]=pll%256; //Write the calculated low-order frequency data into TEA5767
    radio_write_data[2]=0x70; //This is TEA5767 stereo on, mute off
    radio_write_data[3]=0x16; //Chinese standard, using 32768 crystal oscillator, soft mute off, stereo noise cancellation on
    radio_write_data[4]=0x80; //6.5M phase-locked loop on, de-emphasis time 75US
    radio_write();
}


void delay()
{
 uchar k;
 for(k=0;k<100;k++);
}

void desplay(uint aa)
{
 duan=tab[aa/1000]|0x80; //Turn off the decimal point of this digital tube
 led1=0;
 delay();
 led1=1;

 duan=tab[aa%1000/100]|0x80; //Turn off the decimal point of this digital tube
 led2=0;
 delay();
 led2=1;

 duan=tab[aa%100/10]&0x7f; //light up the decimal point of this digital tube
 led3=0;
 delay();
 led3=1;

 duan=tab[aa%10]|0x80; //Turn off the decimal point of this digital tube
 led4=0;
 delay();
 led4=1;
}

 


void main()
{
 radio_write(); //Write to initialize the radio frequency
 while(1)
 {
   if(!KEY1) //Manually set the frequency, +0.1MHz;
   {
     delays(250); //Delay debounce
     frequency+=100;
          if(frequency>108500) //If the frequency is greater than 108.5MHz
          frequency=87500; //Set the frequency to 87.5MHz
   search();
 desplay(frequency/100); //Call display
   }

    if(!KEY2) //manually set frequency, -0.1MHz;
    {
       delays(250); //delay debounce
       frequency-=100;
        if(frequency<87500) //if the frequency is less than 87.5MHz
        frequency=108500; //set the frequency to 108.5MHz
 search();
 desplay(frequency/100); //call display
    }
 desplay(frequency/100); //call display
 }
}

Keywords:TEA5767 Reference address:I made a TEA5767 digital FM stereo radio using a perfboard

Previous article:General EEPROM test program for STC12C2052 and 11/10xx series MCU
Next article:Atmega8 model segmentation difference

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号