# number preloaded into timer (PIC18)

Discussion in 'Homework Help' started by TheRekz, Dec 13, 2009.

1. ### TheRekz Thread Starter New Member

Oct 25, 2009
13
0
If I want a timer with a period of 1 second
The external oscillator is 8 MHZ
The prescaler is set to 128

What number should be preloaded into the timer? I remember there is a formula to do this, but I can't find it... can anyone help me

2. ### beenthere Retired Moderator

Apr 20, 2004
15,808
294
The oscillator outputs 8,000,000 per second. What is left after dividing by 128?

3. ### TheRekz Thread Starter New Member

Oct 25, 2009
13
0
It's 62,500, I know... but is that the number that should be preloaded to the timer?

4. ### beenthere Retired Moderator

Apr 20, 2004
15,808
294
How many counts of (8,000,000/128) = one second?

5. ### TheRekz Thread Starter New Member

Oct 25, 2009
13
0
what do you mean?? how do I know that?

6. ### beenthere Retired Moderator

Apr 20, 2004
15,808
294
It's implicit in the unit - Hertz, which is a measure of cycles per second.

7. ### TheRekz Thread Starter New Member

Oct 25, 2009
13
0
so you mean I need to divide 1/(8,000,000/128)

8. ### beenthere Retired Moderator

Apr 20, 2004
15,808
294
For a digital clock that runs with an line operated supply, you can arrange to use part of the AC waveform to produce a 60 Hz waveform. If you apply that signal to a counter, one second will have elapsed every time the count reaches 60.

A 60 Hz waveform goes through 60 repetitions in one second. An 8 MHz waveform goes through 8,000,000 repetitions in one second. Frequency is always cycles (or repetitions) per second.

9. ### TheRekz Thread Starter New Member

Oct 25, 2009
13
0
so you're saying that 62,500 cycles is equal to 1 second... therefore I should set the count to 62500?