So, this is my first year using MPLab instead of EasyC and I was wondering if there was a way to access a hardware timer at all. I know it can be done, cuz EasyC has a function to do it, but I couldn’t find anything on the forums.
It’s relatively easy. Which version of the code are you using (Kevin’s new code, or the 2007 default code)?
The basics are in http://www.ifirobotics.com/docs/timers_white_paper_2004-jan-14.pdf
But basically you setup the timer, create an ISR that updates some timer variables, and a set of functions that let you read the timer values.
Thanks a lot… I’ll read through that stuff tonight and see what happens. We’re using the default code.
Are all the timers on the PIC18F8520/8722 (TIMER0-4) available for our use, or are some reserved for use by the IFI code?
I’d stay away from TMR0. Its referenced from some routines in ifi_library.c (within the high priority interrupt).
I’m going to answer my own question here. In the IFI 2004 Programming Reference Guide, on page 28, it says that all timers are available to the user for programming, so hopefully that still applies to the 18F8722. I’ll post again after some more testing (notably, when I have a chance to get the values of the TxCON registers during initialisation and runtime). Thanks for your input.
Be sure to use the ifi library FRC_alltimers.lib, rather than FRC_library.lib.
FRC_library.lib in the default code does use Timer 0, but not for any reason you’d probably care about.
Huh… so that’s what that’s for. Thanks for the tip, that definitely removes all doubt about which timers to use.