|
Re: How to use a "Timer"
Quote:
|
Originally Posted by 6600gt
The new PIC is 8722 not 8720 and the processor runs at 40 MHz but the prescaler examples are assuming the procesor is running at 10 MHz.
This is the actual Pic18F8722 data sheet: http://www.kevin.org/frc/PIC18F8722_ds.pdf
That is just he C18 complier library to help with timers and stuff but not the actual Pic data sheet.
|
It wasn't meant to be a link to the datasheet, and yes it is in fact a 10MHz clock. I'm using those to generate a 4ms overflow timer, and I've verified its speed by having a printf every 250 overflows (one second) and timing it with my watch, as well as a few other people who concur, its definitely 10MHz.
Code:
void Initialize_Clock(void)
{
/* Use Timer3 (16-bits) to control our clock */
/* timer set to 4 ms */
OpenTimer3(TIMER_INT_ON &
T3_16BIT_RW &
T3_SOURCE_INT &
T3_PS_1_8
);
// Maximum for 16-bit 65535 - 5000 (4ms) = 60535
WriteTimer3(CLOCKOFFSET); /* Preload timer to overflow after 4ms */
}
Make sure to include timers.h
__________________
Matt Krass
If I suggest something to try and fix a problem, and you don't understand what I mean, please PM me!
I'm a FIRST relic of sorts, I remember when we used PBASIC and we got CH Flightsticks in the KoP. In my day we didn't have motorized carts, we pushed our robots uphill, both ways! (Houston 2003!)
|