I am generating a 30 ms signal using Timer 0 and i toggle a particular pin on a port. I capture this Signal and i want to toggle another pin based upon the Capture IF SET.
My Code
Code: Select all
MCU : PIC16F877A
Crystal Frequency : 8 MHz
// TO Capture a 30 ms signal and to Toggle a port pin.
void interrupt()
{
if(intcon.tmr0if==1)
{
intcon.tmr0if = 0 ;
PORTD.F0 = ~ PORTD.F0;
Tmr0 = 22;
}
else if(PIR1.CCp1if==1)
{
PIR1.CCP1if = 0;
PORTD.F5 = ~ PORTD.F5;
}
else if(PIR1.TMR1IF==1)
{
PIR1.TMR1IF = 0;
}
}
void main()
{
TRISC.F2 = 1; // Config PORTC Pin 2 = Input
TRISD = 0x00; // Config PORTD as output pins
intcon.gie = 1;
intcon.peie = 1;
intcon.T0CS = 0 ; // Timer 0 Internal Clock
intcon.T0SE = 0 ;
TMR0 = 22;
Option_reg = 0x07; //
PIR1.Tmr1IF = 0; // Timer 1 Interrupt Flag Cleared
PIE1.TMR1IE = 1; // Timer 1 Interrupt Enable Set
T1con = 0x01; // Timer 1 Internal Clock
PIR1.CCP1IF = 0; // Capture Flag Clear
PIE1.CCP1IE = 1; // Capture Enable Set
CCP1CON = 5; // Capture Rising Edge
for(;;)
{ // Run a Blank Loop Infintely
}
}
Please help me out with the Capture Module.
Your guidelines are most welcome.
Rob.