Timer SubRoutine


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1


    Did you find this post helpful? Yes | No

    Default Re: Timer SubRoutine

    what speed is the PIC clock? (thats what drives the timers in most cases)
    George

  2. #2


    Did you find this post helpful? Yes | No

    Default Re: Timer SubRoutine

    Quote Originally Posted by towlerg View Post
    what speed is the PIC clock? (thats what drives the timers in most cases)
    I believe the 16F616 has options for either 4MHz or 8MHz internal clock.

  3. #3


    Did you find this post helpful? Yes | No

    Default Re: Timer SubRoutine

    Using the Mikro timer calculator @ 8MHz
    Code:
    'Timer1
    'Prescaler 1:4; TMR1 Preload = 15536; Actual Interrupt Time : 100 ms
     
    'Place/Copy this part in declaration section
    sub procedure InitTimer1()
      T1CON	 = 0x21
      TMR1IF_bit	 = 0
      TMR1H	 = 0x3C
      TMR1L	 = 0xB0
      TMR1IE_bit	 = 1
      INTCON	 = 0xC0
    end sub
     
    sub procedure Interrupt()
      if (TMR1IF_bit) then
        TMR1IF_bit = 0
        TMR1H	 = 0x3C
        TMR1L	 = 0xB0
        'Enter your code here
      end if
    end sub
    Of course the syntax is wrong but the values are correct. I couldn't get 1 second so I did 0.1 second. Same principle count to 10 for one sec and 50 for five sec.
    George

Similar Threads

  1. Subroutine placement - must they come first?
    By BrianT in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 28th August 2012, 12:10
  2. Pulsin within subroutine
    By Wesley in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 10th January 2009, 23:05
  3. subroutine with hserin
    By volcane in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 19th December 2007, 02:56
  4. subroutine question
    By maus in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 11th September 2006, 21:36
  5. subroutine for picbasic
    By jojokatada in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 19th February 2005, 18:58

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