timer/counter questions


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    May 2008
    Location
    Italy
    Posts
    825


    Did you find this post helpful? Yes | No

    Default Re: timer/counter questions

    Robert, without an ISR the timing is not very precise but you can try the following:


    '-------------- set the registers -------------------------------
    T1CON = %00111101 ' set timer1 as timer with prescaler 1:8
    PIE1.0 = 1 ' enable interrupt on overflow
    PIR1.0 = 0 ' clear interrupt flag
    TMR1L = 220 ' 100 millisecs overflow
    TMR1H = 11 ' 100 millisecs overflow
    W_Count VAR WORD
    '-----------------------------------------------------------------

    Poll in the approriate point, somewhere in your program:

    If PIR1.0 = 1 THEN
    T1CON.0 = 0
    PIR1.0 = 0
    TMR1L = 220
    TMR1H = 11
    W_Count = W_Count +1
    T1CON.0 = 1
    endif

    IF W_Count = 300 then
    W_Count = 0
    Do your job since 30 seconds have been elapsed..
    endif

    You can trim the 300 to better achieve the 30 seconds delay. (300 x 100 millisecs = 30 seconds)

    Cheers

    Al.
    All progress began with an idea

  2. #2
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: timer/counter questions

    Robert, If I were you I would look at replacing the OLD 16F877 with something like an 18F4620. If you are using the 40 pin dip package it should drop right in and the part has LOTS more program memory space and Eeprom. Just about all I use these days is the 18F2620 as I don't need all the pins but it has the same amount of memory. Just a thought....

    Dave Purola,
    N8NTA
    Last edited by Demon; - 4th October 2016 at 16:02.

Similar Threads

  1. Two quick (and elementary) questions.
    By scorpion990 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 26th June 2008, 23:03
  2. A few 12F683 questions
    By dhouston in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 24th May 2008, 03:54
  3. Usart Questions
    By shawn in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 8th March 2008, 01:17
  4. Still new to PicBasic - i2c questions
    By cometboy in forum mel PIC BASIC
    Replies: 4
    Last Post: - 13th November 2006, 18:27
  5. Hi Everyone! Some newbie questions :-)
    By guest_05 in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 28th October 2006, 22:24

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