Trying to add a sleep function or pretend to sleep


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    The problem I have is I can not stop Timer1 because that is where the PWM burst happens.

    If I stop this timer I have no way to wake it up so I can not go in sleep mode.

    I can only get the LEDs off based on a counter and I guess compare it with its own value from the previous loop.

    What I can't figure out is, how many loops I get in one minute? and how much can I count with a word variable?

    Perhaps I need to use nested counters? or is there a better way?

  2. #2
    Join Date
    Jul 2003
    Posts
    2,405


    Did you find this post helpful? Yes | No

    Default

    A word var can count up to 65,535. If your Timer1 interrupts happen every 20mS, then count up to 3000.

    It won't be right on the money for 1 second with your delays, HPWM, etc, in your Timer1 interrupt handler, but you can adjust for overhead if you need it closer to 1 second exactly.

    You could also use a Timer0 interrupt to increment your counter.
    Regards,

    -Bruce
    tech at rentron.com
    http://www.rentron.com

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