Searching \ for 'Using capture ports on PIC16C76' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: techref.massmind.org/techref/microchip/ios.htm?key=port
Search entire site for: 'Using capture ports on PIC16C76'.

Truncated match.
PICList Thread
'Using capture ports on PIC16C76'
1999\01\26@174920 by Tolmie, Shane

flavicon
picon face
Hi,

I'm using two capture ports on a pic16c76 to record the number of pulses
coming into the capture ports.

Both ports ccp1 and ccp2 are set up identically.  They interrupt on a
low-high transition, and increment a counter.

However, one works, and the other doesn't.  This is indeed a bit of a
mystery.  I've tried 2 emulators, and burnt two pics,
and the result is invariably the same.  I've spent 1 1/2 weeks on this,
every day, and the answer still eludes me.

The new version of Hi Tech PIC C, 7.82pl2, and the old version was
tested. A goldstar, hp function generator and remote
control servo receiver were used for the pulses into ccp1/rc2 and
ccp2/rc1.

Many thanks,
Shane.
spam_OUTsmt52TakeThisOuTspamelec.canterbury.ac.nz




First, the setup.  I have previously turned off all other interrupts
mentioned on p142, PIC16C7X manual

TRISC=0;    //switch all of port C to outputs, PIC16C7X manual p73,
10.2.1

//initialise capture ports
CCP1IE=0;
CCP1CON=0x05; //0b00000101 - capture mode, every rising edge, p72 in
PIC16C7X manual
CCP1IF=0;
CCP1IE=1;

CCP2IE=0;
CCP2CON=0x05; //0b00000101 - capture mode, every rising edge, p72 in
PIC16C7X manual
CCP2IF=0;
CCP2IE=1;

//turn on all parts of the interrupt tree, p142 PIC16C7X manual
PEIE=1;
GIE=1;


Then, the portion of code in the interrupt isr():

static void
interrupt isr (void)
{
 //capture port 2 (RC1) <-this one doesn't work
 if (CCP2IF)
 {
   x=CCPR2L;             <-putting a break point here reveals that it
never gets here at all
   y=CCPR2H;
   ccp2_counter++;
   CCP2IF=0;
 }
 //capture port 1 (RC2) <-this one works perfectly as expected
 if (CCP1IF)
 {
   a=CCPR1L;             <-putting a break point here works perfectly
   b=CCPR1H;
   ccp1_counter++;
   CCP1IF=0;
 }
}

1999\01\26@182456 by mwestfal

flavicon
face
Tolmie, Shane wrote:
>
> TRISC=0;    //switch all of port C to outputs, PIC16C7X manual p73,
> 10.2.1

But don't you want RC1 and RC2 to be inputs?

Not that that section 10.2.1 is for compare mode, not capture mode.


-------------------------------------------------------------------------------
Mike
.....mwestfalKILLspamspam@spam@odc.net
http://web.csusb.edu/public/csci/mwestfal
Linux religious dogma: "The Gates of Hell shall not prevail."
-------------------------------------------------------------------------------

More... (looser matching)
- Last day of these posts
- In 1999 , 2000 only
- Today
- New search...