Hardware timers


Closed Thread
Results 1 to 10 of 10

Thread: Hardware timers

Hybrid View

  1. #1
    Join Date
    Jun 2008
    Posts
    30

    Post Hardware timers

    I'm using "COUNT" command to count the number of pulses coming in but now i need to use the hardware timers. I want to count my pulse for 30 seconds, i was thinking of using TMR2 8 bit with prescaler. I'm using a PIC16F873 with a 20 Mhz crystal, could anyone let me know how to approach this.

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


    Did you find this post helpful? Yes | No

    Default

    Are you trying to use a timer for the 30 second period, or trying to use a timer/counter?
    Regards,

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

  3. #3
    Join Date
    Jun 2008
    Posts
    30


    Did you find this post helpful? Yes | No

    Smile Hardware timers

    I would just like to use the hardware timers, just to pause for 30 seconds so in the mean time my pic can keep running and keep collecting data for that 30 sec.


    thanks

  4. #4
    Join Date
    Nov 2005
    Location
    Bombay, India
    Posts
    966


    Did you find this post helpful? Yes | No

    Default

    I would think, you need a timer to keep count of the seconds. Any timer would do fine as long as you know how to extend it, in code, to count 1 second. This timer can then be further extended to count the 30 seconds interval you want.

    Similarly, the pulses could come into the INT pin on your device and you could count the interrupt when it occurs.

    Just ideas you could evaluate

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


    Did you find this post helpful? Yes | No

    Default

    Why not just let the timer/counter count your pulses?

    MyCount VAR WORD

    TMR1L=0 ' clear the low byte
    TMR1H=0 ' clear the high byte
    T1CON = %00000011 ' set Timer1 up as a hardware counter

    This counts rising edge pulses on RC0. The count is held in TMR1L and TMR1H.

    Do whatever you need to collect other data for 30 seconds then just read the count.

    MyCount.LowByte = TMR1L
    MyCount.HighByte = TMR1H

    You could set Timer1 to overflow, count overflows incrementing a variable, but it would be
    a lot easier using a built-in hardware counter. And it doesn't interrupt whatever else your
    program is doing. It counts in the background.
    Regards,

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

  6. #6
    Join Date
    May 2008
    Posts
    21


    Did you find this post helpful? Yes | No

    Default

    When I had to learn how to use timers, I used this thread.

    This thread also happens to have EXACTLY what you want... a timer that counts down from 30.

    http://www.picbasic.co.uk/forum/show...hlight=O_FLOWS

    Sorry the link highlights O_FLOWS, I just happen to rememberthat variable so used it to find the thread.
    Also wish I'd have read the forum sooner >.<;

Similar Threads

  1. Timers
    By mitchf14 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 15th November 2008, 20:08
  2. using hardware ports
    By sebapostigo in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 19th November 2007, 22:01
  3. Reading Timers
    By kevj in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 27th August 2007, 08:19
  4. hardware timers
    By Adam in forum General
    Replies: 3
    Last Post: - 7th March 2007, 00:10
  5. Bootloader Hardware Modification
    By NavMicroSystems in forum Schematics
    Replies: 1
    Last Post: - 5th August 2004, 00: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