Timer using Picbasic Pro


Closed Thread
Results 1 to 15 of 15

Hybrid View

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


    Did you find this post helpful? Yes | No

    Default

    Have a look at Olympic Timer (search the forum) to give you an idea of how TMR1 could be used to increment variables to count whatever time period you require.

  2. #2
    Brutis's Avatar
    Brutis Guest


    Did you find this post helpful? Yes | No

    Default Re-Olympic Timer.

    Hi Melanie,

    Thanks for the link. Did not fully understand all the code. Would you happen to know the simplist way to acheive a 1 second rate using the timer1. I'm using a 0.5 second rate now but I need more time to execute my code. 1 second would be great before the flag gets set. Any idea how to do this.

    Thanks

    Regards,

    Brutis.

  3. #3
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Datasheet! *sigh*

    Timer1 ticks every 1uS @ 4MHz.

    It's 16 bits wide, therefore with a 4MHz clock will time 65.536mS between each Flag.

    Using the 1:8 prescaler your maximum time is 8*65.536mS=524.288mS

    So unless Microchip has shoved hardware into your PIC that mine doesn't have, the answer is NO, Timer1 will NEVER tick 1 second @ 4MHz.

    You can always use a Bit Variable as a Flag... If BitFlag=0 and Timer1Flag then half a second has elapsed - so Set the BitFlag. If BitFlag=1 and Timer1Flag then one second has elapsed, so reset the BitFlag and start over for a new Second.

    Homework: What has Timer2 got that Timer1 doesn't have?

  4. #4


    Did you find this post helpful? Yes | No

    Default homework

    Timer2 has a prescaler and a postscaler. Am I right Melanie, am I right??

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


    Did you find this post helpful? Yes | No

    Default

    Yup, you're right... Homework Part Deux: Which now means what's the maximum Time you can let Timer2 run for at 4MHz with all the prescalers and postscalers enabled?

  6. #6


    Did you find this post helpful? Yes | No

    Default homework

    Boy - you're putting me through the mill. I come up with 16.777 seconds. Am I right... am I right??

  7. #7
    Join Date
    Jul 2003
    Posts
    2,358


    Did you find this post helpful? Yes | No

    Default

    Close, but no cigar...(we're talking about Timer2 in a PIC16F876/877)...

Similar Threads

  1. can anyone here can convert this in picbasic pro?
    By reianjim in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 3rd December 2009, 12:43
  2. Replies: 3
    Last Post: - 1st July 2008, 22:07
  3. How to configure SPI in PICBASIC PRO?
    By moogle in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th April 2007, 19:31
  4. Question for all that use MELABS PICBASIC PRO
    By oskuro in forum Off Topic
    Replies: 2
    Last Post: - 24th March 2005, 18:15
  5. PicBasic Pro & PicBasic syntax different
    By Billyc in forum General
    Replies: 5
    Last Post: - 16th April 2004, 22:19

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