May 4, 2013 #1 J john120 Banned Joined Aug 13, 2011 Messages 257 Helped 11 Reputation 22 Reaction score 10 Trophy points 1,298 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
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
May 4, 2013 #2 jayanth.devarayanadurga Banned Joined Dec 4, 2012 Messages 4,280 Helped 822 Reputation 1,654 Reaction score 791 Trophy points 1,393 Location Bangalore, India Activity points 0 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.
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.
May 4, 2013 #3 J john120 Banned Joined Aug 13, 2011 Messages 257 Helped 11 Reputation 22 Reaction score 10 Trophy points 1,298 Activity points 0 jayanth.devarayanadurga said: 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. Click to expand... 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.
jayanth.devarayanadurga said: 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. Click to expand... 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.