HI,
I am working on capture mode for measuring pulse at pic input pin...
here is code pls have a look is that fine after that i will watch on lcd..
I am working on capture mode for measuring pulse at pic input pin...
here is code pls have a look is that fine after that i will watch on lcd..
Rich (BB code):
#include<pic.h>
#define _XTAL_FREQ 20000000L
__CONFIG(0x3F18);
unsigned char low,high;
void main (void){
TRISC2=1;
CCP1CON=0b00000101;//Capture mode, every rising edge
T1CON=0b00001001;//Internal clock,Enables Timer1
TMR1IF =0;
TMR1H = 0x00;
TMR1L = 0x00;
GIE =1; // Interrupt Enable
PEIE =1;
CCP1IE =1;
while(1){}
}
static void interrupt isr(void) {
if ( CCP1IF ) {
low=CCPR1L;
high=CCPR1H;
CCP1IF = 0;
}
// if timer interrupt: reset timer and toggle Port B.2
if ( TMR1IF ) {
TMR1H = 0x00; TMR1L = 0x00;
TMR1IF = 0;
}
}