PDA

View Full Version : 18F2620 32mhz pll and Timer1 250ms ticks



retepsnikrep
- 9th February 2017, 16:28
I think i have configured my 18F2620 to run at 32mhz. Prev 8mhz and timer1 4hz ticks no problem.

Now i'm after Timer1 interrupting every 250ms with clock running at 32mhz..

Using mister e's calculator T1CON seems to need a 1/32 prescaler. But i don't see how to select that. Not listed?..

Am I missing something or is a 1/32 prescaler just not available with the 18F2620.

TMR1CS seems to suggest a 1/4 divider from fosc? I'm a bit confused..

HenrikOlsson
- 9th February 2017, 17:15
That's correct, 1:32 is not available - and I'm pretty sure that's not specific to the 18F2620.

When the instruction clock is selected as the source for TMR1 then it's Fosc/4 so for your 32MHz clock the timer would run at 8MHz. You will not be able to get 250ms "in one go" when running at such high speed as 32MHz. What you need to do then is make it interrupt at some faster rate, say 25ms and then count ten interrupts for a total duration of 250ms.

An alternative is of course to connect a 32.768kHz crystal to the TMR1 oscillator pins and run it off of that.

/Henrik.