Electronics > Beginners

making a frequency measurement meter with LCD display

(1/1)

khatus:
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: ---#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;

    }
}
}
--- End code ---


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








 

hexreader:
Solution already given here:

https://forum.mikroe.com/viewtopic.php?f=88&t=75001

Navigation

[0] Message Index

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod