asking
Full Member level 5
- Joined
- Sep 21, 2010
- Messages
- 279
- Helped
- 6
- Reputation
- 12
- Reaction score
- 6
- Trophy points
- 1,298
- 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
}
}