TMR0 Confusion


Results 1 to 16 of 16

Thread: TMR0 Confusion

Threaded View

  1. #11


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Confusion

    Thanks it's working on the bench now just need to check my TMR0 calculations.

    Using http://eng-serve.com/pic/pic_timer.html I get a prescaler of 1/4 and preload of 6 giving 500us interrupts (2khz) so that gives me 250 ticks per cycle with 8mhz clock.

    That works out at 2.5ticks per 1% duty.
    So for 10% duty I need to load 25 + 6 into TMR0 for the 90% off part of the cycle? and 225 + 6 for the 10% on part of the cycle?
    Does that look sound right?

    So my modified code looks like this.

    Code:
        TMR0_ON_TICKS = DutyCycle           '(DutyCycle must be between 25 - 225 (10-90%)
        TMR0_OFF_TICKS = 250 - TMR0_ON_TICKS
        TMR0_ON_VAL = 250 - TMR0_ON_TICKS + 6
        TMR0_OFF_VAL = 250 - TMR0_OFF_TICKS + 6
    Last edited by retepsnikrep; - 4th August 2011 at 07:32.

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts