TMR3SETUP Issue

iGull

New Member
Hi All

Having some probs with tmr3setup - I'm using a 28X2 part at 8MHz in this application. The language guide says ...

"The internal timer counts, when enabled, at a rate of (1/resonator speed) / 4. This means, for instance, at 8MHz the internal timer increment occurs every 0.5us.
This value can be optionally scaled by the prescale value (set via bits 5:4) , so with a 1: 8 prescale the increment will occur every 4us (8 x 0.5us). "

(1/8E6)/4 = 0.03125 uS according to my aged calculator - a factor of 16 out.
The prescaler maxes out at 1:8 so we're still a factor of two out :))

The application I'm working on actually requires 10mS - 1/100th of a second interrupts which need to be accurate.

Can anyone suggest a solution?

TIA

Neil
 

hippy

Ex-Staff (retired)
I think this is a problem relating to time and frequency (t=1/f) and translation of one to the other and I think (1/resonator speed) / 4 should be (1/resonator speed) * 4 or 4 / resonator speed.

So at 8MHz the timer3 increments 4/8E6, every 0.5us at a frequency of 2MHz

With a prescalar of 8, the timer3 ticks only every 8 x 0.5us (4us) at a frequency of 250kHz.

Reciprocol numbers (1/N) can be a pain to get one's head around as witnessed in converting mph to kph. 1 mile is 1.609344 kilometers, so a mph speed is less than kph but it's not uncommon to end up with an mph to kph conversion equation which works opposite to that and a lot of head-scratching !
 
Last edited:

iGull

New Member
So at 8MHz the timer3 increments 4/8E6, every 0.5us at a frequency of 2MHz

With a prescalar of 8, the timer3 ticks only every 8 x 0.5us (4us) at a frequency of 250kHz.!
Thanks for that correction Hippy - that makes sense - perhaps someone can make a mental note to edit the manual and perhaps include your wee explanation as a hint at the same time ?

Cheers

Neil
 
Top