>-----Original Message----- >From: piclist-bounces@mit.edu [mailto:piclist-bounces@mit.edu] >On Behalf Of Johan Rantala >Sent: 24 November 2004 08:12 >To: Microcontroller discussion list - Public. >Subject: Re: [PIC] Period of square-wave > > >On Wed, 24 Nov 2004, Mike Singer wrote: > >> Johan Rantala wrote: >> >> > > What's the range of the period? >> > >> > about 10uS - 100uS >> >> >> What's the PIC16F877A OSC frequency? >> Why not reveal this kind of basic info in the beginning to sharp the >> problem instead of sinking into possibly non-consistent solution ;-) >> > >Yeah, you're so right ;) >I'm using a 20Mhz external crystal. > >> At 20 MHz PIC16F877A you have only 40 instructions per 10 >microsecond >> period. Not that many for C language. Perhaps you should switch to: >> - assembler; >> - PIC18Fxxx; >> - TIP #2 Measuring the Period of a Square Wave _with Averaging_ > >So the CCP-module with my PIC16F877A >is out of the question for measuring these kind of periods? >Would it help to use every 16th rising edge? Not at all, the CCP is the exact peripheral you need to use. However, depending on your requirements, the resolution may be a little marginal. Timer1 has a minimum period of 1/(20MHZ/4)=200ns, giving you a count of between 50 and 500. Configuring the CPP to trigger pn every 16th edge would obviously improve this somewhat. If you need even more resolution you can take multiple readings and average them. Regards Mike ======================================================================= This e-mail is intended for the person it is addressed to only. The information contained in it may be confidential and/or protected by law. If you are not the intended recipient of this message, you must not make any use of this information, or copy or show it to any person. Please contact us immediately to tell us that you have received this e-mail, and return the original to us. Any use, forwarding, printing or copying of this message is strictly prohibited. No part of this message can be considered a request for goods or services. ======================================================================= _______________________________________________ http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist