Help NeededCapture Module:

General discussion on mikroC.
Post Reply
Author
Message
Rob1234
Posts: 31
Joined: 11 Aug 2009 04:13

Help NeededCapture Module:

#1 Post by Rob1234 » 10 Feb 2011 09:32

Dear Readers,

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
}
}
When the code is executed, PORTD.F2 generates a good square wave of 30 ms interval.. but .. the PORTD.F5 doesnt toggle..

Please help me out with the Capture Module.

Your guidelines are most welcome.

Rob.

Post Reply

Return to “mikroC General”