I'm just starting out with timers on microcontrollers and part of my assignment requires me to write a value to timer0 in order for it to increment after a specified time. What confuses me is that I thought that the timer can either act as a timer/counter where the time taken for it to it to increment and overflow in timer mode is dependent mainly on the prescaler value. So why would one write a value to the timer0 register and would it be as simple as saying

MOVLW 0x20



closed as unclear what you're asking by Eugene Sh., pipe, Voltage Spike, Dmitry Grigoryev, Autistic Mar 29 '17 at 9:49

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    \$\begingroup\$ Think about 'the time taken for it to it to increment and overflow' if you start it at a value which is not 0 ... \$\endgroup\$ – brhans Mar 27 '17 at 20:13

I don't have the datasheet at hand, but let's say you've setup the prescaler so that a full timer0-overflow (0xFF -> 0x00) occurs every 1 second.

Now let's say that, with the same setup, you want an interrupt every 0.5 second instead. What you do then is to preload the TMR0 register with 0x80. This way, it will have the first half second "already filled up", so to speak, and at every interrupt you just reload TMR0 with 0x80 again.

And yes, it's as simple as just movwf:ing into the register.


Not the answer you're looking for? Browse other questions tagged or ask your own question.