kirangowle
New Member
Hello all,
I am new to this forum.
I have a requirement where i need to read the specific pattern of pulse.
Please refer the attached screenshot contains the specific pattern of data s inform Pulse.
Googling i found that i need to use Capture mode to read the pulse width and compare against the duration of it.
To start off with, First i am trying to capture the interrupt. but unfortunately its not working.
My code looks like below
void interrupt ISR()
{
/*if(TMR1IF)
{
TMR1IF = 0;
RD2 ^=1;
}*/
if(CCP1IF)
{
CCP1IF = 0;
RD2 ^=1;
}
}
// Main Function
void main(void)
{
unsigned char ch;
RD2 = 0;
TRISD2=0;
TRISC2 = 1;
//RC2=1;
TMR1H = 19;
TMR1L = 19;
T1CON = 0x31;
/* configure capture unit */
CCPR1H=0x00;
CCPR1L=0x00;
CCP1CON = 0x05;
CCP1IE = 1;
CCP1IF = 0;
/* configure interrupts */
TMR1IE = 1;
PEIE = 1;
PIR1 = 1;
INTCON=0xC0;
while(1)
{
}
}
FYI. i am attaching project files along with proteus simulator design.
Thanks in advance
Kiran
I am new to this forum.
I have a requirement where i need to read the specific pattern of pulse.
Please refer the attached screenshot contains the specific pattern of data s inform Pulse.
Googling i found that i need to use Capture mode to read the pulse width and compare against the duration of it.
To start off with, First i am trying to capture the interrupt. but unfortunately its not working.
My code looks like below
void interrupt ISR()
{
/*if(TMR1IF)
{
TMR1IF = 0;
RD2 ^=1;
}*/
if(CCP1IF)
{
CCP1IF = 0;
RD2 ^=1;
}
}
// Main Function
void main(void)
{
unsigned char ch;
RD2 = 0;
TRISD2=0;
TRISC2 = 1;
//RC2=1;
TMR1H = 19;
TMR1L = 19;
T1CON = 0x31;
/* configure capture unit */
CCPR1H=0x00;
CCPR1L=0x00;
CCP1CON = 0x05;
CCP1IE = 1;
CCP1IF = 0;
/* configure interrupts */
TMR1IE = 1;
PEIE = 1;
PIR1 = 1;
INTCON=0xC0;
while(1)
{
}
}
FYI. i am attaching project files along with proteus simulator design.
Thanks in advance
Kiran