anjalimidhuna
Member level 3
- Joined
- Jan 4, 2014
- Messages
- 62
- Helped
- 2
- Reputation
- 4
- Reaction score
- 2
- Trophy points
- 8
- Location
- india
- Activity points
- 358
Code:
void interrupt isr(void)
{
if(TMR1IF==1)
{
Count++;
tmr++;
if(tmr==1000)
{
tmr=0;
lcd++;
}
TMR1IF=0;
TMR1H=0XFC;
TMR1L=0X17;
}
if(CCP1IF==1)
{
if(flag==0)
{
flag=1;
Count=0;
}
else
{
if(Count>0)
{
freq=Count;
flag=0;
}
}
CCP1IF=0;
}
}
void main()
{
T1CON=0b00000001; // INITIALISE TIMER1 CONTROL REGISTER
TMR1H=0XFC; // LOAD VALUE TO HIGHER BYTE REGISTER
TMR1L=0X17; // LOAD VALUE TO LOWER BYTE REGISTRE
INTCON=0b11000000; // INITIALISE INTERRUPT CONTROL REGISTER
PIE1=0b00000101; // INITIALISE TIMER INTERRUPT CONTROL REGISTER
Lcd_Init();
adc_init();
while(1)
{
if(lcd>=1)
{
LCD(Lcd_clear,ModCmd);
Delay_ms(100);
LCD(FstLin_FstColumn,ModCmd);
freq=Count;
freq=freq*2;
if(freq>0)
value=1000000/freq;
Disp_STRING("FREQUENCY=");
Disp_STRING(int_to_string(value,buf));
Disp_STRING("Hz");
lcd=0;
}
}
}
even for the same frequency it gives value like
499
333
249
.
.
.
.
.18
i am using PIC16F877A with hi tech c