Frequency Counter using PIC and PicBasic


Results 1 to 32 of 32

Threaded View

  1. #29
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Here's the basic of TIMER1

    Timer1 is act as a back ground counter on RB6 pin on the PIC16F628. It store the result in TMR1L and TMR1H register.

    So you need to:
    • 1. set TMR1L and TMR1H to 0, to make the counter begin count at 0.
      2. start the counter By using T1CON=7

    The above set timer to:
    • 1. No sychro from the internal to the internal clock [bit 2]
      2. Use external RB6 as clock source [bit 1]
      3. Enable timer1 [bit 0]

    then after you just have to wait for the sampling time you want to use. Once it's finish. stop the timer with T1CON=0

    Now your result is store into internal register TMR1L and TMR1H in two Byte format. Place them into one WORD variable and display your count

    MyCount var word

    MyCount.lowbyte=TMR1L
    MyCount.HighByte=TMR1H

    lcdout $FE,1,"MyCount",#Mycount

    you can test if the TIMER1 has overflow by testing PIR1.0 If 0 then there's no overflow. If 1... TIMER1 has overflow.

    If it has overflow, you must clear it by software PIR1.0=0
    Last edited by mister_e; - 27th January 2005 at 19:47.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. using AND as an IF statement
    By dw_pic in forum mel PIC BASIC
    Replies: 27
    Last Post: - 8th June 2006, 19:05
  2. Need help deciding = BASCOM 0r PICBASIC
    By Chris DeHut in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 26th January 2006, 17:38
  3. Replies: 22
    Last Post: - 12th July 2005, 18:39
  4. Pic To Pic Serial Communication?
    By ngeronikolos in forum mel PIC BASIC Pro
    Replies: 19
    Last Post: - 5th February 2005, 01:59
  5. PicBasic Fundamentals
    By Billyc in forum General
    Replies: 9
    Last Post: - 4th May 2004, 11:04

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