Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Helpful change for frequency counter using PIC 16F877A in ccs c compiler

Status
Not open for further replies.

john120

Banned
Full Member level 5
Joined
Aug 13, 2011
Messages
257
Helped
11
Reputation
22
Reaction score
10
Trophy points
1,298
Visit site
Activity points
0
Can some body plz help me to modify the following codes for counting the frequency up to 2Mhz of a square wave and sine wave:

#include <16f877a.h>
#use delay(clock=20M)
#include <lcd420.c>
#include <LCD_D.h>
#fuses hs,nowdt,nocpd,nolvp,noprotect

#byte portc=0x07
#bit led=portc.4

void LCD_D();
unsigned int16 value;

void main()
{
set_tris_c(0x00);
led=1;
delay_ms(500);
LCD_D();
delay_ms(50);
while(1)
{
set_timer1(0);
setup_timer_1(t1_external | T1_DIV_BY_1);
delay_ms(1000); // in protues, should be 1000/3

setup_timer_1(T1_DISABLED);
value=get_timer1();
lcd_gotoxy(11,4);
printf(lcd_putc,"%LU HZ ",value);
led=!led;
}
}

I got those codes from http://www.pic-tronics.com/Frequency-Counter-Using-PIC16F877A.php

Thanks
 

Timer1 is a 16-bit timer. Max value is 65535. Try using CCP1 pin in Capture mode to find the period and frequency of square wave.

Yeah the Maximum with Timer1 is 65535 but;I solved the problem buy chaning the delay time and the prescaler for Timer1 see the following:
setup_timer_1(T1_EXTERNAL|T1_DIV_8)

then the delay has been changed to 250ms.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top