Need help using capture inputs on 16F877
Dan Michaels email (remove spam text)
Fred Bailey wrote:
>I'm having trouble with the capture input CCP1. I have capture input CCP2
>I have tested the Port C - I/O by disabling both capture modules and reading
> All bits work OK (Hi and Low). But, I can't get CCP1 (RC2 input) to capture. I
>have also tried
>using CCP1 and CCP2 together and separately Only CCP2 works.
>I initialize the CCP1 as follows:
>Setup_capture ; RC1input pulse, 50uSec wide every 16.6mSec, use capture2
Hi Fred, I have some suggestions here.
1 - I don't see you configuring the port direction bits.
2 - I don't see you doing a global interrupt enable, or resetting
the relevant intr flag.
3 - I would not turn on Timer 1 until everything else was setup and ready
to go. You do this in your first couple statements.
4 - Timer 1 is going to clock out very fast, probably < 1 sec, depending
upon the xtal in use, so you have to get right on the job with your
input signal soon as you run this code, else you will miss the event.
5 - You also have to jump thru a few hoops in order to avoid false captures,
as detailed in the spec sheet.
6 - During development, I would first get this code working correctly
in polled mode rather than interrupt mode - ie, simply poll the
interrupt flag, and read the register. Fewer things to get confused
hope this helps,
- dan michaels
http://www.piclist.com#nomail Going offline? Don't AutoReply us!
email mitvma.mit.edu with SET PICList DIGEST in the body listserv
See also: www.piclist.com/techref/microchip/ios.htm?key=input
You must be a member of the
piclist mailing list
(not only a www.piclist.com member) to post to the