FMUSER Wirless Transmit Video And Audio More Easier !

[email protected] WhatsApp +8618078869184
Language

    ATMEGA8 control BH1415F program

     

    Name :: RF transmitter BH1415F
     
         
    Time :06 -07-06
         
    Functions: control BH1415F FM transmitter frequency range (88 ~ 108Hz) MCU: ATMEGA8
         
    Write: LCJ
    ************************************************** ************ /
    / * ___________________________________________________
      
    CE ___ |

    | __________
               
    ________________
      
    CK _____ | | __ | | __ | | __ | | __ | | _ ---- _ | | __ | | __ |

    | __________
             
    __________
      
    DA____ | D0 | __ | D1 | __ | D2 | __ | D3 | __ | D4 | __
           
    ______
    ----- _ | PD | __ | T1 | __ | T2 | __________
    * /
    / **********************************
       
    Digital FM transmitter program
    *********************************** /
    / / Header file
    # Include <iom8v.h> / / SCM Model Options
    # Include <macros.h> / / bit definitions
    # Include <eeprom.h> / / EEPROM memory
    / / Crystal frequency
    # Define fosc 6000000 / / crystal 6MHZ
    # Define baud 9600 / / baud rate

    # Define open_radio (PINB & 0B00000100) / / boot
    # Define function_open (PORTB | = (1 << 4)) / / control boot
    # Define function_close (PORTB & = ~ (1 << 4)) / / control shutdown
    # Define open_save (PINB & 0B00000100) / / open storage station
    # Define save_ensure (PINB & 0B00000100) / / storage station determines
    # Define adjust_station (PINB & 0B00000100) / / regulation kept good radio
    # Define F_ADD (PINB & 0B00001000) / / frequency plus
    # Define F_REDUCE (PINB & 0B00010000) / / frequency less reduce
    / / Unsigned char F_DATA_H, F_DATA_L ;/ / frequency of high and low bit
    unsigned char open_radio_flag ;/ / boot flag

    / / Unsigned char F_flag_H ;/ / frequency storage of high
    / / Unsigned char F_flag_L ;/ / low frequency storage

    unsigned char LCD_display_H ;/ / LCD high
    unsigned char LCD_display_L ;/ / LCD low

    unsigned char function_flag ;/ / save Taiwan flag

    unsigned char save_dais_flag ;/ / deposit determined logo

    # Define save1_H (PORTC | = (1 << 4)) / / status indication to defend Taiwan
    # Define save2_H (PORTC | = (1 << 5)) / / Paul station indicating success
    # Define save1_L (PORTC & = ~ (1 << 4))
    # Define save2_L (PORTC & = ~ (1 << 5))

    # Define LED_H (PORTD | = (1 << 7))

    # Define CE_H (PORTB | = (1 << 0)) / / 15 CE
    # Define CE_L (PORTB & = ~ (1 << 0))
    # Define CK_H (PORTB | = (1 << 1)) / / 16 CLOCK
    # Define CK_L (PORTB & = ~ (1 << 1))
    # Define DA_H (PORTB | = (1 << 5)) / / 17 DATA
    # Define DA_L (PORTB & = ~ (1 << 5))
    / / # Define LCD_display_OUT PORTB
    / / # Define LCD_display_control PORTC
    / / Unsigned char LCD_display_data [8] [4];
    unsigned char display_character [10] = {0x3f, 0X06, 0X5B, 0X4F,

    0X66, 0X6D, 0X7D, 0X07, 0X7F, 0X6F} ;/ / matrix 1, 2, 3, 4, 5, 6, 7, 8, 9
    unsigned char EEPROM_READ_DATA ;/ / read the saved data
    unsigned char EEPROM_READ_NUMBER ;/ / read the saved address
    / ************************************************* ******* /
    unsigned char display_one ;/ / display bits
    unsigned char display_ten ;/ / display ten
    unsigned char display_hundred ;/ / display one hundred
    unsigned char display_thousand ;/ / display one thousand
    / ************************************************* *******
                      
    Display data buffer
    ************************************************** ****** /
    unsigned char temp_display_one;
    unsigned char temp_display_ten;
    unsigned char temp_display_hundred;
    unsigned char temp_display_thousand;
    / ************************************************* ******
                   
    To control BH1415 data buffer
    ************************************************** * /
    unsigned char temp_BH1415_one;
    unsigned char temp_BH1415_ten;
    unsigned char temp_BH1415_hundred;
    unsigned char temp_BH1415_thousand;
    / ************************************************* * /
    unsigned char BH1415_one ;/ / BH1415 control bits
    unsigned char BH1415_ten ;/ / BH1415 control ten
    unsigned char BH1415_hundred ;/ / BH1415 control one hundred
    / ************************************************* * /
    unsigned char adjust_PS8889_OUT ;/ / output control number
    unsigned char adjust_PS8889_control [9] ;/ / control array
    / / Unsigned char adjust_station_number ;/ / check the number of bits of the array
    unsigned char adjust_save_address ;/ / save address
    unsigned char adjust_save_function ;/ / save function
    / ************************************************* ******* /
    unsigned char temp_BH1415_L ;/ / control the BH1415 low 8
    unsigned char temp_BH1415_H ;/ / control BH1415 8

    / **************************************** /
    void delay_ms (void);
    void delay_xs (unsigned char x);
    void adjust_station_OUT (void);
    void station_save_IN (void);
    void EEPROM_rite (unsigned int uAddr, unsigned char uData);
    void EEPROM_read (unsigned int uAddr);
    void F_ADD_function (void);
    void F_REDUCE_function (void);
    void control_BH1415_and_display (void);
    void LCD_display (unsigned char display_data, unsigned char

    function_number);
    void control_BH1415 (void);
    void BH1415_OUT (unsigned char control_F_DATA, unsigned char

    control_number);
    / ************************************************* ****** /


    / / Delay subroutine
    void delay_xs (unsigned char x)
    {
       
    unsigned char a;
       
    for (a = 0; a <x; a + +)
       
    {
         
    delay_ms ();
      
    }
    }

    void delay_ms (void)
    {
      
    unsigned char aa, bb;
      
    for (aa = 0; aa <50; aa + +)
      
    {
         
    for (bb = 0; bb <100; bb + +);
      
    }
    }

    / *********************************
            
    Following is a reading desk function
    ********************************** /
    void adjust_station_OUT (void)
    {/ / Store a good radio regulation
       
    EEPROM_read (EEPROM_READ_NUMBER);
       
    temp_display_one = EEPROM_READ_DATA;
       
    EEPROM_READ_NUMBER + +;
     
       
    EEPROM_read (EEPROM_READ_NUMBER);
       
    temp_display_ten = EEPROM_READ_DATA;
       
    EEPROM_READ_NUMBER + +;
     
       
    EEPROM_read (EEPROM_READ_NUMBER);
       
    temp_display_hundred = EEPROM_READ_DATA;
       
    EEPROM_READ_NUMBER + +;
     
       
    EEPROM_read (EEPROM_READ_NUMBER);
       
    temp_display_thousand = EEPROM_READ_DATA;
       
    EEPROM_READ_NUMBER + +;
      
    }

    void station_save_IN (void)
    {/ / Store radio function
      
    EEPROMwrite (adjust_save_address, temp_display_one);
      
    adjust_save_address + +;
     
      
    EEPROMwrite (adjust_save_address, temp_display_ten);
      
    adjust_save_address + +;
     
      
    EEPROMwrite (adjust_save_address, temp_display_hundred);
      
    adjust_save_address + +;
     
      
    EEPROMwrite (adjust_save_address, temp_display_thousand);
      
    adjust_save_address + +;
    }
    / *********************************
         
    EEPROM read function
    ********************************** /
    void EEPROM_read (unsigned int uAddr)
    {/ / Read EEPROM function
      
    while (EECR & (1 << EEWE));
      
    EEAR = uAddr;
      
    EECR | = (1 << EERE);
      
    EEPROM_READ_DATA = EEDR;
    }

    / ************************************
            
    Here is the frequency gradually add function
    ************************************* /
    void F_ADD_function (void)
    {/ / Frequency gradually increased function, / / ​​frequency decreasing function initialization F_DATA_H = 0X03, F_DATA_L = 0X66
        
    if (temp_display_thousand> = 0x01)
       
    {
         
    if (temp_display_ten> = 0x08)
      
    {/ / Limit the maximum frequency 108.0MHZ
         
    temp_display_one = 0x00;
      
    temp_display_ten = 0x08;
      
    temp_display_hundred = 0x00;
      
    temp_display_thousand = 0x01;
      
    }
      
    else
      
    goto ADD;
      
    }
      
    else
      
    {
    ADD: temp_display_one + +;
     
    if (temp_display_one> = 0x0a)
     
    {
         
    temp_display_one = 0x00;
         
    temp_display_ten + +;
         
    if (temp_display_ten> = 0x0a)
            
    {
              
    temp_display_ten = 0x00;
           
    temp_display_hundred + +;
           
    if (temp_display_hundred> = 0x0a)
           
    {
               
    temp_display_hundred = 0x00;
         
    temp_display_thousand + +;
         
    if (temp_display_thousand> = 0x01)
              
    {
          
    if (temp_display_ten> = 0x08)
          
    {
             
    temp_display_one = 0x00;
             
    temp_display_ten = 0x08;
             
    temp_display_hundred = 0x00;
          
    temp_display_thousand = 0x01;
             
    }
               
    }
         
            
    }
      
           
    }
          
    }
      
     
    }

       
    control_BH1415_and_display () ;/ / output control BH1415 launch
     
    }
    / ****************************************
       
    Here is the frequency decreasing function
    **************************************** /
    void F_REDUCE_function (void)
    {/ / Frequency gradually increased function, / / ​​frequency decreasing function initialization F_DATA_H = 0X03, F_DATA_L = 0X66
       
    if (temp_display_thousand <= 0x00)
       
    {/ / Limit minimum frequency 87.0MHZ
         
    if (temp_display_hundred <= 0x08)
      
    {
        
    if (temp_display_ten <= 0x07)
        
    {
          
    if (temp_display_one <= 0x00)
          
    {
              
    temp_display_one = 0x00;
           
    temp_display_ten = 0x07;
           
    temp_display_hundred = 0x08;
           
    }
          
    else
       
    goto REDUCE;
         
    }
      
    else
      
    goto REDUCE;
      
    }
      
    else
      
    goto REDUCE;
      
    }
      
    else
      
    {
    REDUCE: if (temp_display_one <= 0x00)
     
    {/ / Decreasing Start
         
    temp_display_one = 0x0a;
         
    if (temp_display_ten <= 0x00)
            
    {
              
    temp_display_ten = 0x0a;
           
    if (temp_display_hundred <= 0x00)
           
    {
              
    temp_display_hundred = 0x0a;
        
    temp_display_thousand = 0x00;
           
    }
       
    temp_display_hundred -;
         
    }
      
    temp_display_ten -;
          
    }
        
    temp_display_one -;
      
     
    }
     
    control_BH1415_and_display ();
    }
    void control_BH1415_and_display (void)
    {/ / Control BH1415 and display output
        
    unsigned char temp_one, temp_ten, temp_hundred, temp_one_L;
     
    unsigned int temp_BH1415_data1,

    temp_BH1415_data2, temp_BH1415_data3;
     
    / ************************************************ /
     
    / / Convert control BH1415 computing.
     
    temp_BH1415_data1 = temp_display_thousand * 1000

    + Temp_display_hundred * 100 + temp_display_ten * 10 + temp_display_one;
     
    temp_BH1415_data2 = temp_BH1415_data1;
     
    temp_BH1415_data3 = temp_BH1415_data2 >> 8;
     
    temp_ten = temp_BH1415_data3;
     
    temp_BH1415_L = temp_BH1415_data1;
     
    temp_BH1415_one = temp_BH1415_L & 0x0f;
     
    temp_BH1415_ten = temp_BH1415_L >> 4 & 0x0f;
     
    temp_BH1415_hundred = temp_ten & 0x0f;
     
    temp_BH1415_H = temp_ten | 0x48
     
     
    / * Temp_ten = temp_BH1415_ten << 4;
     
    temp_ten = temp_ten &0xf0;
     
    temp_BH1415_L = temp_ten + temp_BH1415_one;
     
    temp_BH1415_H = temp_BH1415_hundred | 0x48 * /
     
    / / Temp_BH1415_L = temp_ten + temp_BH1415_one
     
     
    / **************************************** /
     
    / / Output 16-bit serial data control BH1415
     
    CE_L;
     
    CK_L;
     
    DA_L;
     
    NOP ();
     
    NOP ();
     
    NOP ();
     
    CE_H;
        
    BH1415_OUT (temp_BH1415_L, 0x08);
     
    CK_L;
     
    BH1415_OUT (temp_BH1415_H, 0x08);
     
    CE_L;
     
    CK_L;
     
    DA_L;
    }


    / *******************************************
        
    Here is the output function
    ******************************************* /
    void LCD_display (unsigned char display_data, unsigned char

    function_number)
    {/ / LCD output
       
    delay_ms ();
       
    PORTC = function_number;
       
    PORTD = display_character [display_data];
    }


    / ********************************************
       
    Here is the control BH1415 ~ ~ ~ 8-bit transmit serial data function
    ********************************************* /

    void BH1415_OUT (unsigned char control_F_DATA, unsigned char

    control_number)
    {/ / Control BH1415
        
    unsigned char i;
        
    for (i = 0; i <8; i + +)
        
    {
          
    if (control_F_DATA & 0x01 == 0x01)
            
    DA_H;
          
    else
           
    DA_L;
        
    NOP ();
        
    NOP ();
           
    CK_H;
           
    delay_ms ();
           
    NOP ();
           
    NOP ();
           
    CK_L;
           
    NOP ();
           
    NOP ();
          
    control_F_DATA >> = 1;
       
    delay_ms ();
       
    }
    }


    / ***************************************
        
    Below is kept Desk function
    **************************************** /
    void check_save_dais (void)
    {/ / Save table function
        
    display_one = 0x01;
     
    display_ten = 0x00;
        
    display_hundred = 0x00;
     
    display_thousand = 0x00;
     
    adjust_save_address = 0x00 ;/ / initialized memory table address
        
    while (save_dais_flag <= 5)
     
    {
         
    if (open_radio == 0)
         
    {/ / Save the station determines
           
    delay_xs (20);
        
    if (open_radio == 0)
        
    {
           
    station_save_IN () ;/ / EEPRAM save Taiwan and function
        
    save_dais_flag = 6;
        
    delay_xs (20);
          
    }
          
    }
        
    else if (F_ADD == 0X00)
        
    {/ / Save the station plus
           
    delay_xs (20);
           
    if (F_ADD == 0X00)
        
    {
           
    display_one + +;
           
    adjust_save_address + = 4; / / save address plus four
           
    if (display_one> = 9)
        
    {/ / Limit memory station number 9
           
    adjust_save_address = 36;
        
    display_one = 9;
        
    }
             
    }
           
    }
          
    else if (F_REDUCE == 0)
          
    {/ / Save desk Less
             
    delay_xs (20);
             
    if (F_REDUCE == 0)
             
    {
          
    display_one -;
          
    adjust_save_address - =

    4 ;/ / temp_adjust_save_address-4 ;/ / memory address minus four
             
    if (display_one <= 0x01)
          
    {
             
    adjust_save_address = 0x00;
          
    display_one = 0x01;
          
    }
              
    }
        
            
    }
       
    / *********************************
        
    Output displays the deposit station location
        
    ********************************* /
          
    LCD_display (display_one, 0xFE);
          
    LCD_display (display_ten, 0xFD);
          
    LED_H;
          
    LCD_display (display_hundred, 0xFB);
          
    LCD_display (display_thousand, 0xF7);
             
    }
             
    save_dais_flag = 0x00 ;/ / memory table to determine the flag is cleared
       
    function_flag = 0x00 ;/ / save Taiwan flag is cleared
      
    }
    void main (void)
    {
       
    / / Port initialization
       
    unsigned char i, aaw, y, x, TEMP;
       
    DDRB = 0X00;
       
    PORTB = 0XFF;
       
    DDRC = 0XFF;
       
    PORTC = 0X0F;
       
    DDRD = 0XFF;
       
    PORTD = 0XFF;
        
    x = 0x00;
        
    y = 0x9d;
       
    PORTC = y;
       
    CE_L;
       
    CK_L;
       
    DA_L;
       
       
    / / Start frequency 87.0MHZ
       
    temp_display_one = 0x00;
       
    temp_display_ten = 0x07;
       
    temp_display_hundred = 0x08;
       
    temp_display_thousand = 0x00;
      
    / * Control the BH1415 data buffer * /
       
    temp_BH1415_one = 0x06;
       
    temp_BH1415_ten = 0x06;
       
    temp_BH1415_hundred = 0x03;
       
    temp_BH1415_thousand = 0x00;

       
    / / Variable initialization
       
    / / F_DATA_H = 0x00;
      
    / / F_DATA_L = 0x00; / / frequency of high and low bit
       
      
    / / F_flag_H = 0x00 ;/ / frequency storage high
      
    / / F_flag_L = 0x00 ;/ / store low frequency
      
      
    / / LCD_display_H = 0x00 ;/ / LCD high
      
    / / LCD_display_L = 0x00 ;/ / LCD low
      
       
    EEPROM_READ_DATA = 0x00 ;/ / read the saved data
       
    EEPROM_READ_NUMBER = 0x00 ;/ / read the saved address
      
       
    / / Adjust_PS8889_OUT = 0x00 ;/ / output control number
      
      
    / / Adjust_station_number = 0x00 ;/ / check the number of bits of the array
      
       
    adjust_save_address = 0x00 ;/ / memory address is cleared
       
    adjust_save_function = 0x00 ;/ / save function
      
    / ************************************************* ******* /
       
    temp_BH1415_L = 0x00 ;/ / control the BH1415 low 8
       
    temp_BH1415_H = 0x00 ;/ / control BH1415 8
     
       
    open_radio_flag = 0x00 ;/ / boot marked cleared
      
       
    function_flag = 0x00 ;/ / save Taiwan flag
      
       
    save_dais_flag = 0 ;/ / memory table to determine the flag is cleared
      
       
    while (1)
      
    {
         
    if (open_radio == 0)
         
    {/ / Key query boot
           
    delay_xs (10);
        
    if (open_radio == 0)
        
    {
          
    open_radio_flag = 1;
         
    }
     
    while (open_radio_flag == 1)
       
    {/ / Key query, the transfer station
         
    if (open_radio == 0)
         
    {
         
    delay_xs (10);
         
    if (open_radio == 0)
      
    {
         
    do
         
    {/ / Long press to save Taiwan and function
             
    delay_xs (10);
             
    function_flag + +;
          
    if (function_flag> = 50)
         
    {
             
    save1_L;
             
    delay_xs (250);
             
    save1_H;
          
    }
           
           
    }
          
    while (open_radio <= 0);
             
    if (function_flag> = 50)
             
    {
             
    check_save_dais (); / / jump to keep Taiwan functions
            
    function_flag = 0x00 ;/ / save Taiwan flag is cleared
         
    }
        
    else
         
    {
        
    if (EEPROM_READ_NUMBER> = 36)
         
    {/ / Read tune the station a limit to the number of cycles output: 0 to 9 units
             
    EEPROM_READ_NUMBER = 0;
        
    }
             
    adjust_station_OUT () ;/ / read the output of the transfer station
         
    function_flag = 0x00 ;/ / save Taiwan flag is cleared
        
    }
       
    }
          
    }
         
    else if (F_ADD == 0)
         
    {/ / Frequency plus
           
    delay_xs (10);
           
    if (F_ADD == 0X00)
           
    F_ADD_function () ;/ / frequency increases
          
    }
         
    else if (F_REDUCE == 0)
         
    {/ / Frequency reduction
           
    delay_xs (10);
           
    if (F_REDUCE == 0X00)
           
    F_REDUCE_function () ;/ / frequency reduction
          
    }
     
    / / Output display
     
    LCD_display (temp_display_one, 0xFE);
     
    LCD_display (temp_display_ten, 0xFD);
     
    LED_H;
     
    LCD_display (temp_display_hundred, 0xFB);
     
    LCD_display (temp_display_thousand, 0xF7);

     

     

     

     

    List all Question

    Nickname

    Email

    Questions

    Our other product:

    Professional FM Radio Station Equipment Package

     



     

    Hotel IPTV Solution

     


      Enter email  to get a surprise

      fmuser.org

      es.fmuser.org
      it.fmuser.org
      fr.fmuser.org
      de.fmuser.org
      af.fmuser.org ->Afrikaans
      sq.fmuser.org ->Albanian
      ar.fmuser.org ->Arabic
      hy.fmuser.org ->Armenian
      az.fmuser.org ->Azerbaijani
      eu.fmuser.org ->Basque
      be.fmuser.org ->Belarusian
      bg.fmuser.org ->Bulgarian
      ca.fmuser.org ->Catalan
      zh-CN.fmuser.org ->Chinese (Simplified)
      zh-TW.fmuser.org ->Chinese (Traditional)
      hr.fmuser.org ->Croatian
      cs.fmuser.org ->Czech
      da.fmuser.org ->Danish
      nl.fmuser.org ->Dutch
      et.fmuser.org ->Estonian
      tl.fmuser.org ->Filipino
      fi.fmuser.org ->Finnish
      fr.fmuser.org ->French
      gl.fmuser.org ->Galician
      ka.fmuser.org ->Georgian
      de.fmuser.org ->German
      el.fmuser.org ->Greek
      ht.fmuser.org ->Haitian Creole
      iw.fmuser.org ->Hebrew
      hi.fmuser.org ->Hindi
      hu.fmuser.org ->Hungarian
      is.fmuser.org ->Icelandic
      id.fmuser.org ->Indonesian
      ga.fmuser.org ->Irish
      it.fmuser.org ->Italian
      ja.fmuser.org ->Japanese
      ko.fmuser.org ->Korean
      lv.fmuser.org ->Latvian
      lt.fmuser.org ->Lithuanian
      mk.fmuser.org ->Macedonian
      ms.fmuser.org ->Malay
      mt.fmuser.org ->Maltese
      no.fmuser.org ->Norwegian
      fa.fmuser.org ->Persian
      pl.fmuser.org ->Polish
      pt.fmuser.org ->Portuguese
      ro.fmuser.org ->Romanian
      ru.fmuser.org ->Russian
      sr.fmuser.org ->Serbian
      sk.fmuser.org ->Slovak
      sl.fmuser.org ->Slovenian
      es.fmuser.org ->Spanish
      sw.fmuser.org ->Swahili
      sv.fmuser.org ->Swedish
      th.fmuser.org ->Thai
      tr.fmuser.org ->Turkish
      uk.fmuser.org ->Ukrainian
      ur.fmuser.org ->Urdu
      vi.fmuser.org ->Vietnamese
      cy.fmuser.org ->Welsh
      yi.fmuser.org ->Yiddish

       
  •  

    FMUSER Wirless Transmit Video And Audio More Easier !

  • Contact

    Address:
    No.305 Room HuiLan Building No.273 Huanpu Road Guangzhou China 510620

    E-mail:
    [email protected]

    Tel / WhatApps:
    +8618078869184

  • Categories

  • Newsletter

    FIRST OR FULL NAME

    E-mail

  • paypal solution  Western UnionBank OF China
    E-mail:[email protected]   WhatsApp:+8618078869184   Skype:sky198710021 Chat with me
    Copyright 2006-2020 Powered By www.fmuser.org

    Contact Us