View Single Post
  #3   Spotlight this post!  
Unread 02-12-2004, 01:04
Kevin Watson's Avatar
Kevin Watson Kevin Watson is offline
La Caņada High School
FRC #2429
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: La Caņada, California
Posts: 1,335
Kevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond reputeKevin Watson has a reputation beyond repute
Re: Is there a built in tick/millisecond counter?

Quote:
Originally Posted by Aalfabob
My first question is, are there any counters built into the main unit?

If there is, how would i access it?
The edu_clock example that does what you want can be found here: http://kevin.org/frc/. It's for the EDU-RC, but should be easy to adapt to the FRC-RC. This is the header of clock.c:


Code:
/*******************************************************************************
*
* TITLE: clock.c 
*
* VERSION: 0.3 (Beta) 
*
* DATE: 18-Dec-2003
*
* AUTHOR: R. Kevin Watson
* kevinw@jpl.nasa.gov
*
* COMMENTS: This demonstrates the use of a timer and associated interrupt.
* In this example we'll setup a timer to generate an interrupt 
* every millisecond (= 1000Hz rate). In response to this interrupt,
* the microcontroller will execute a specific piece of code called
* an interrupt handler (see user_routines_fast.c). This interrupt
* handler will simply increment the global variables "msClock" and
* "Clock". High-level user code can then access these variables to 
* create sophisticated state machines and highly accurate sequencers.
* We'll just keep the time.
* 
*
********************************************************************************
*
* Change log:
*
* DATE REV DESCRIPTION
* ----------- --- ----------------------------------------------------------
* 14-Dec-2003 0.1 RKW Original
* 16-Dec-2003 0.2 Accuracy bug: Changed the value of PR2 to 249 (was 250)
* 18-Dec-2003 0.3 Fixed 25 hour/day and 366 day/year bugs
*
*******************************************************************************
Let me know if you have any trouble.

-Kevin
__________________
Kevin Watson
Engineer at stealth-mode startup
http://kevin.org