[PIC] PIC16F877A PIC Capture Mode Not working

Status
Not open for further replies.

asking

Full Member level 5
Joined
Sep 21, 2010
Messages
279
Helped
6
Reputation
12
Reaction score
6
Trophy points
1,298
Visit site
Activity points
3,377
i need to detect PWM signal of 50HZ. I have written simple code just to turn on led on Every Rising Edge. But my CCP Capture mode is not running. Please look at code, anything missing ? Please help..

Code:
// Interrupt Handler
void interrupt()
{

  // CCP1 Interrupt
  if(PIR1.CCP1IF == 1)   // if the CCP1 Interrupt flag is set...
  {
    PORTB.F5 = 1;
     PIR1.CCP1IF = 0;
  }
  else PORTB.F5 = 0;
}


void main() {
ADCON1 = 0x07;
CMCON = 0x07;
TRISA = 0b00000000;
PORTA = 0;
PORTB = 0;
PORTC = 0;
PORTD = 0;
TRISB = 0b00000000;
TRISC = 0b00000100;
TRISD = 0b00000000;


//CCP1 MODULE INITIALIZATION

T1CON = 0b00110001;
CCP1CON = 0b00000101;
INTCON = 0b11000000;


while(1)
{
// write program here
}

}
 

add CCP1IE=1; IN MAIN FUNETION. this will enable ccp1 interrupt

- - - Updated - - -

GIE=1; THIS WILL ENABLES THE GLOBAL INTERRUPT, with out setting this bit no interrupts will work

- - - Updated - - -

u are just checking the flag, with out enable the appropriate interrupt
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…