Jump to content
Fórum Script Brasil
  • 0

DUVIDA COM CODIGO DE PLL FM


Question

Olá amigos!

Abaixo está um código que encontrei para um PLL FM, mas ele não exibe a informação como deveria...

Preciso de exiba 107.100 e atualmente está 1071... Conforme imagem abaixo...

Os botões movimentam a frequência nos 1.2.3.4.5.6.7.8.9.0 ... e existe um ajuste no código para adicionar os 00 ao final.

Alguém sabe como inserir o ponto antes das 3 ultimas casas?

image.png.aa5059a89a4596d8c533fd9e8a3b2c78.png

 

#include <16F628A.h>

#FUSES NOWDT                    //No Watch Dog Timer
#FUSES HS                       //High speed Osc (> 4mhz for PCM/PCH) (>10mhz for PCD)
#FUSES NOPUT                    //No Power Up Timer
#FUSES PROTECT                  //Code protected from reads
#FUSES NOBROWNOUT               //No brownout reset
#FUSES MCLR                     //Master Clear pin enabled
#FUSES NOLVP                    //No low voltage prgming, B3(PIC16) or B5(PIC18) used for I/O
#FUSES NOCPD                    //No EE protection

#use delay(clock=4000000)

#include "lcd_flex.c"

#define ste_mono input(pin_a3)
#define sobe input(pin_b0)
#define desce input(pin_b1)

#define data  pin_a1
#define clock  pin_a2
#define eneble pin_a0

int co_sterio;
int16 frequence = 1071;
unsigned short st = 0;
unsigned short i;



     void clk_PLL(void)  
    {
      delay_us(10);
      output_high(clock);
      delay_us(10);
      output_low(clock);
      delay_us(10);
    }  

  int16 masque;
 

void sendBH1415() {
   int n;

      output_high(eneble);  // ENB=1
      delay_us(10);
      for (n=0; n<11; n++)
        {
           masque = (1 << n); 
          if ( (frequence & masque) != 0)   output_high(data);   
          else  output_low(data);
          clk_PLL();
     
        }
   
   
    for (n=0;  n<=4; n++)    
    {
      masque = (1 << n);  
     if (co_sterio & masque) output_high(data);  
     else  output_low(data); 
 
     clk_PLL();
    }
   output_low(eneble);       // CE low
}



void main()
{



     lcd_init();

      printf(lcd_putc," \f %lumhz",frequence);
      lcd_gotoxy(1,2);
      printf(lcd_putc,"  PLL BH 1415");
   
     co_sterio = 8; //= mono
     sendBH1415();
   while(TRUE)
   {
   
 
   
 if(!ste_mono  )
  {
   st = ~ st;
   delay_ms(300);
   i=1;
  }
  
      if(st == 1 )
      {
      lcd_gotoxy(11,1);
      printf(lcd_putc,"sterio");
      co_sterio = 9;
           if(i == 1)
             { 
             sendBH1415();
             delay_ms(300);
             sendBH1415();
             i=0;
             }
      }else
      {
      co_sterio = 8;
      lcd_gotoxy(11,1);
      printf(lcd_putc," mono ");
      
          if(i == 1)
             { 
             sendBH1415();
             delay_ms(300);
             sendBH1415();
             i=0;
             }
      
         
      }
 
 
           lcd_gotoxy(1,1);
           printf(lcd_putc,"%lu00mhz", frequence);
   
             if(!sobe)
                  {
                      frequence ++;
                      sendBH1415();
                      delay_ms(200);
                  }
  
  
             if(!desce)
               {
                  frequence --;
                  sendBH1415();
                  delay_ms(200);
               }
               
       
   }

}

 

Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Forum Statistics

    • Total Topics
      148692
    • Total Posts
      644524
×
×
  • Create New...