Timer using Picbasic Pro


Closed Thread
Results 1 to 15 of 15

Hybrid View

  1. #1
    Brutis's Avatar
    Brutis Guest

    Default Timer using Picbasic Pro

    Good Day,

    If anyone has code examples in Picbasic Pro using Timer1 Module for Pic16F876 & Pic16F877 and using a 4Mhz clock. That would be great. I basically need a 0.5 second timer so I can execute another function in the code.


    Thank You

    Brutis

  2. #2
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Default

    Brutis,

    Had you visioned using PBP interrupts, "Instant Interrupts," ASM interrupts, or polling for TMR1 overflows? This might help people help you.

    Paul Borgmeier
    Salt Lake City, Utah
    USA

  3. #3
    Brutis's Avatar
    Brutis Guest


    Did you find this post helpful? Yes | No

    Default Tmr1

    Hi Paul,

    Thanks for the reply, I'm using the timer1 module in PBP. But I cannot seem to get a 1 second timer from this. The most I can get is 5.24 ms before the interrupt flag gets set. Do you know how I can get a 1 second timer form TMR1?

    Regards,

    Brutis

  4. #4
    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.

  5. #5
    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.

  6. #6
    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?

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, 11:43
  2. Replies: 3
    Last Post: - 1st July 2008, 21:07
  3. How to configure SPI in PICBASIC PRO?
    By moogle in forum mel PIC BASIC Pro
    Replies: 13
    Last Post: - 15th April 2007, 18:31
  4. Question for all that use MELABS PICBASIC PRO
    By oskuro in forum Off Topic
    Replies: 2
    Last Post: - 24th March 2005, 17:15
  5. PicBasic Pro & PicBasic syntax different
    By Billyc in forum General
    Replies: 5
    Last Post: - 16th April 2004, 21:19

Members who have read this thread : 1

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