Hardware timers


Closed Thread
Results 1 to 10 of 10

Thread: Hardware timers

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    At 20MHz, if you're using the internal clock, Timer1 will count to 65,535, then roll-over on
    the next tick in just 13.1072mS with a 1:1 prescaler.

    If you set the prescaler to 1:8 it would take 8 times this period before it rolls-over. The
    only way you could use Timer1 for a 10 second delay period would be to monitor & count
    over-flows until your 10 second period is up.

    Unless you're just trying to learn to use timers, a long pause would be the easiest.

    Steve has a nice utility here: http://www.mister-e.org/pages/utilitiespag.html you might
    find helpful. Check out the timer helper.
    Regards,

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

  2. #2
    Join Date
    Mar 2006
    Location
    Pennsylvania, USA.
    Posts
    130


    Did you find this post helpful? Yes | No

    Default

    For a long delay like 9 seconds, I use Steve's calculator utility to set up a timer to go for 10 milliseconds. Then I use Darrell's Instant Interrupts, and set up an interrupt, let's say for Timer 3. I just set my variable seconds to 0, and then enable the timer interrupt. When the 10 ms. is up, the interrupt goes to the following;

    '********************** TIMER 3 INTERRUPT*************************************
    TIMER3INT: 'THIS INTERRUPT OCCURS EVERY 10 MILLISECONDS
    TICKS = TICKS + 1 'INCREMENT TICKS
    IF TICKS > 100 THEN
    TICKS = 0
    SECONDS = SECONDS + 1
    ENDIF
    @ INT_RETURN
    '********************** END TIMER 3 INTERRUPT ********************************
    now I just add a line in my main program to see if seconds is equal to nine, and when it is I disable the interrupt and go do what ever comes next. This works well if I'm waiting for a user to make a selection, I'll wait ten seconds, and if they don't respond, then the program will move on.

    Good Luck!

    Jerry.
    If your oscilloscope costs more than your car...

  3. #3
    Join Date
    Jun 2008
    Posts
    30


    Did you find this post helpful? Yes | No

    Smile Hardware timers

    Wow that Picmulticalc is really amazing thanks for referring me to it i will defiantly be using it.
    I don't need to use a interrupt. Right now i am using a really long pause 10 sec, so when my battery charges up to 9 volts my led comes on saying the battery is fully charge. Then i have my pause that checks back in ten seconds if my battery is still full or not. The only things i don't like about this process is that for that seconds my pic hangs and all my other operations are on a alt until the 10 seconds is completed. Now i was thinking if i could figure out how to use the hardware timers, my timers could count in the background without affecting my ADC, and LCD etc.

    Could anyone clarify this for me and maybe suggest a better way of doing this.

    thanks

Similar Threads

  1. Timers
    By mitchf14 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th November 2008, 21:08
  2. using hardware ports
    By sebapostigo in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 19th November 2007, 23:01
  3. Reading Timers
    By kevj in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th August 2007, 09:19
  4. hardware timers
    By Adam in forum General
    Replies: 3
    Last Post: - 7th March 2007, 01:10
  5. Bootloader Hardware Modification
    By NavMicroSystems in forum Schematics
    Replies: 1
    Last Post: - 5th August 2004, 01:46

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