TMR0 Confusion


Closed Thread
Results 1 to 16 of 16

Thread: TMR0 Confusion

Hybrid View

  1. #1
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Confusion

    Prescaler should be set and forget as I understand it
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Confusion

    When you use the USART, are you setting the Baudrate after each character sent? Nope!

    When you use the CCP module in PWM mode, do you need to configure the frequency each time you want to play with the duty cycle? Nope!

    Internal hardware are often like so, you set them, you forget them.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Confusion

    That's why i'm confused the 12F683 data sheet says that writes to the TMR0 reg clear the prescaler :?

    The prescaler is not readable or writable. When
    assigned to the Timer0 module, all instructions writing to
    the TMR0 register will clear the prescaler.

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Confusion

    mm, seems I need to send my crystal ball again for repair... she don't want to tell me the PIC you're using
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Aug 2010
    Location
    Maryland, USA
    Posts
    869


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Confusion

    That can be a little confusing. the prescaler keeps a count. Say it is set up for 1:8, it will count to 8 then roll over. the roll over is the new tmr count. When you write the tmr0 they are saying the count in pre scale will be reset back to 0. so if it had a count of 5, it will be cleared to zero. But the amount of pre scale will persist, it will still be 1:8

    Steve, she just needs glasses, look above the quote
    -Bert

    The glass is not half full or half empty, Its twice as big as needed for the job!

    http://foamcasualty.com/ - Warbird R/C scratch building with foam!

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Confusion

    Thanks for that CNC! makes sense. I'm using a 12F683 FYI. I'll do some bench testing

  7. #7
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,604


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Confusion

    Hi,
    Now I note you cant stop/start TMR0 I dont think that's a major issue in my application which is generating a 2khz pwm.
    You can't stop TMR0 when its in timer mode but you can switch it from timer- to counter mode which, as long as you don't have a any pulses coming on the T0CKI pin, will have the same effect as stopping it. As always YMMV but it's a "trick" that might work.

    /Henrik.

  8. #8


    Did you find this post helpful? Yes | No

    Default Re: TMR0 Confusion

    Quote Originally Posted by HenrikOlsson View Post
    Hi,

    You can't stop TMR0 when its in timer mode but you can switch it from timer- to counter mode which, as long as you don't have a any pulses coming on the T0CKI pin, will have the same effect as stopping it. As always YMMV but it's a "trick" that might work.

    /Henrik.
    That's sneaky!!

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