View Single Post
  #18   Spotlight this post!  
Unread 12-02-2006, 01:27
Matt Krass's Avatar
Matt Krass Matt Krass is offline
"Old" and Cranky. Get off my lawn!
AKA: Dark Ages
FRC #0263 (Sachem Aftershock)
Team Role: Mentor
 
Join Date: Oct 2002
Rookie Year: 2002
Location: Long Island, NY
Posts: 1,187
Matt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond reputeMatt Krass has a reputation beyond repute
Send a message via AIM to Matt Krass
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!)