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