Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Forums > Electronic Projects Design/Ideas/Reviews


Electronic Projects Design/Ideas/Reviews Are you building an electronic project or want to? Maybe you need some assistance? Come and submit your electronic questions here and let our experienced members find a solution.

Reply
 
Tools
Old 22nd January 2008, 11:27 PM   #1
Default determining what frequency of crystal to use?

Ok, I'm still learning this micro controller stuff. You all have pointed me in the direction of some very informative reading (which I really appreciate) but I still have a few fuzzy areas that I need cleared up.

In reviewing options, I see that there are a number of solutions to use as a timing circuit for a micro controller. I'm using a PIC16F876 and am wondering what to use as my timing circuit. It looks like a quartz crystal would be a stable solution and appears that it is connected across pins 9 and 10, OSC1 and OSC2 respectively, obviously with some supportive circuitry (caps) as well. My question is, how do you determine what frequency of crystal to use? This particular PIC is rated at 20MHz so I'm assuming I would want to use a 20MHz crystal. What advantage is there to using a lower frequency crystal?

I've read through the PIC data sheets and am trying to get a handle on TIMER0, TIMER1, and TIMER2 as well. It looks like TIMER0 & TIMER1 are software selectable internal or external and that it can be set to Timer Mode or Counter Mode. Timer Mode is incremented with every instruction cycle and Counter Mode is incremented on ever rising or falling edge of the T0CK1 pin. What would be the benefits of each of these modes? I assume that every instruction begins exactly 200 ns after the last one when using a 20MHz crystal?

Last edited by bigfarmerdave; 22nd January 2008 at 11:29 PM.
bigfarmerdave is offline  
Old 23rd January 2008, 01:44 AM   #2
Default

Quote:
Originally Posted by bigfarmerdave
I'm using a PIC16F876 and am wondering what to use as my timing circuit. It looks like a quartz crystal would be a stable solution and appears that it is connected across pins 9 and 10, OSC1 and OSC2 respectively, obviously with some supportive circuitry (caps) as well. My question is, how do you determine what frequency of crystal to use? This particular PIC is rated at 20MHz so I'm assuming I would want to use a 20MHz crystal. What advantage is there to using a lower frequency crystal?
You need to use a lower frequency crystal if the operating voltage is lower.

The power consumption is approximately proportional to frequency so a lower frequency will reduce the power.

If you need particular timing, for instance for baud rate generation, frequencies that are a power of 2 multiple of the baud rate can make the frequency division easier. E.g. 38,400 baud * 256 * 2 = 19.6608 MHz

An oscillator can be connected directly to the OSC1 pin and no other components are needed.

Quote:
Originally Posted by bigfarmerdave
I've read through the PIC data sheets and am trying to get a handle on TIMER0, TIMER1, and TIMER2 as well. It looks like TIMER0 & TIMER1 are software selectable internal or external and that it can be set to Timer Mode or Counter Mode. Timer Mode is incremented with every instruction cycle and Counter Mode is incremented on ever rising or falling edge of the T0CK1 pin. What would be the benefits of each of these modes?
It is just whether you want to count time from the internal clock or external pulses. The external pulses might represent something other than time or it might be more accurate than the PIC clock. For timing, if the PIC clock is accurate enough for your purposes, use it.

Quote:
Originally Posted by bigfarmerdave
I assume that every instruction begins exactly 200 ns after the last one when using a 20MHz crystal?
Yes, except for 2 cycle instuctions like GOTO, CAll etc
Diver300 is offline  
Reply

Tags
crystal, determining, frequency

Thread Tools
Display Modes


Similar
Title Starter Forum Replies Latest
Variable capacitor circuits walters General Electronics Chat 92 7th February 2009 08:08 PM
89c52 crystal frequency gondu Micro Controllers 2 9th January 2008 07:40 PM
how and where to connect crystal for fix frequency to use multiple remote bells in sa parveenarora General Electronics Chat 2 1st April 2007 01:18 PM
Crystal frequency redart Datasheet/Parts Requests 4 10th May 2006 08:26 AM
Help with Crystal frequency generator 7404 quad2 input Electronic Projects Design/Ideas/Reviews 2 10th December 2004 05:19 PM



All times are GMT. The time now is 03:25 AM.


Electronic Circuits  |  Learning Electronics
eXTReMe Tracker