Author Topic: making a frequency measurement meter with LCD display  (Read 596 times)

0 Members and 1 Guest are viewing this topic.

Offline khatusTopic starter

  • Regular Contributor
  • *
  • Posts: 147
  • Country: gl
making a frequency measurement meter with LCD display
« on: July 22, 2019, 03:14:38 pm »
Hello guys i am currently making a frequency meter using pic 18f4550 micro controller. Here is my code written in mikroc pro for pic

Code: [Select]
#define f_timer 2000000
sbit LCD_RS at LATB4_bit;
sbit LCD_EN at LATB5_bit;
sbit LCD_D4 at LATB0_bit;
sbit LCD_D5 at LATB1_bit;
sbit LCD_D6 at LATB2_bit;
sbit LCD_D7 at LATB3_bit;



sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
void main ( void )
{
unsigned long signal_period,data1,data2;
unsigned long frequency_Hz[20];
float Frequency;
TRISC.TRISC2=1;
OSCCON=0b1110000;
PIE1.CCP1IE=1;
PIR1.CCP1IF=0;
CCP1CON=0x05;
CCPR1=0x00;
PIR1.TMR1IF=0;
T1CON=0x80;
TMR1H=0;
TMR1L=0;
T1CON.TMR1ON=1;
Lcd_Init();
TRISB = 0;
TRISA = 0;
PORTA = 0;


while( 1 )
{

while(!(PIR1.CCP1IF));
PIR1.CCP1IF=0;
data1 = CCPR1;
while(!(PIR1.CCP1IF));
PIR1.CCP1IF=0;
data2 = CCPR1;

if(data1 < data2)
           {
            signal_period = data2 - data1;
            Frequency = ((float)f_timer / (float)signal_period);
            FloatToStr( Frequency,frequency_Hz );
            Lcd_Out_Cp(frequency_Hz);
           while(1)
           {

            }
        TMR1H=0;
        TMR1L=0;

    }
}
}


The code compiled successfully.The problem is the LCD display did not show any value.Can anybody correct my code??








 
« Last Edit: July 22, 2019, 03:22:30 pm by khatus »
 

Offline hexreader

  • Frequent Contributor
  • **
  • Posts: 263
  • Country: england
Re: making a frequency measurement meter with LCD display
« Reply #1 on: July 22, 2019, 05:08:51 pm »
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf