View Single Post
  #10   Spotlight this post!  
Unread 26-02-2007, 00:17
Dave K.'s Avatar
Dave K. Dave K. is offline
Engineer/Mentor
FRC #0930
Team Role: Mentor
 
Join Date: Jan 2007
Rookie Year: 2005
Location: WI
Posts: 91
Dave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to beholdDave K. is a splendid one to behold
Re: Real time clocks, out of the question?

Quote:
Originally Posted by evan_wilson View Post
Ahhh, that explains things a bit. I should have thought about that. RD16 two bytes wide, duh.

Thanks for that tidbit.

And the high and low bytes. In the wallclock code (http://www.chiefdelphi.com/forums/sh...t=wallclock.c), the high byte value is.... NEVER MIND

Someone can't count their zeros.

I still don't exactly understand what the purpose of the high and low bytes are. Is it like an loop condition? Above the max value for a 16bit number counts as an overflow and it resets, setting the flag with it?

THANK YOU

One of the interrupt options is to interrupt on timer overflow, and that is how some of the other examples posted work.

If you:

- stop the timer
- load a 16 bit value into the timer register
- reset the interrupt flag
- start the timer

You will get an overflow interrupt in however many timer ticks it takes for the pre-load value to reach the point of overflow (0xffff -> 0x0000).


Having the timer value available could also be useful for calculating the period between two events, such as a transition on an input pin that triggers an interrupt. The input interrupt could read the current timer value, and subtract the timer value of the last input transition to calculate the amount of time elapsed since the last input interrupt.

Ideally, one would use something like the CCP module to time stamp an input transition, but in the case of IFI's RC, those pins aren't available as for user Digital I/O pins.

As an example, for something like motor velocity control, at slow speeds, if a rotational speed slower than 1 pulse per sample period was desired, you could use period measurement to gain some additional resolution, and above a certain rotational speed, you could switch to counting the number of pulses per period method.

Each microcontroller manufactuer has their own ideas on the degree's of flexibility that they make available. Microchip's 8 bit PIC family is pretty average. Some parts have less flexibility, others have quite a bit more. In this case, you have to do the best you can with what they give you...
__________________
--Dave