Expanding Timer1 counting range


Results 1 to 15 of 15

Threaded View

  1. #11
    Join Date
    Dec 2007
    Location
    Malaysia
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    Not that I can't think out of the box, but I've asked around and tried whatever is possible, to display counting in LCD, not to display in LCD, to display only the final value, etc, but i still can't manage to get the timer to display in 1ms timing interval. I know that the PIC can continue counting by itself, but, even I try to make it display only the final value, but it still can't display the accurate readings.

    Sorry for asking questions that might consider too easy for some others, but I am totally new in this. I need the timer to measure the human response time.

    MY CODE:

    'MAIN PROGRAM
    '------------
    ResetTimer:
    GoSub SetReg
    LCDOUT $FE, 1
    Timer1H = 0
    Timer1L = 0
    MicroThousandths = 0
    Thousandths = 0
    Hundredths =0
    Seconds = 0

    Main:
    LCDOUT $FE, $80, "Test Mode 1"
    'LCDOUT $FE, $C0, "Visual Response Test"
    If ButStart = 1 Then goto StartTimer
    Goto Main

    StartTimer:
    LCDOUT $Fe, 1
    LCDOUT $FE, $80, "Calculating..."
    T1CON.0=1

    Looping:
    While PIR1.0=0
    Wend
    PIR1.0=0
    Thousandths=Thousandths+1
    If Thousandths>9 Then
    Thousandths=0
    Hundredths=Hundredths+1

    If Hundredths>99 Then
    Hundredths=0
    Seconds=Seconds+1
    Endif
    Endif

    If ButStop = 1 Then goto StopTimer
    Goto Looping

    StopTimer:
    T1CON.0 = 0
    LCDOUT $Fe, 1
    GoSub GetValue

    DisplayResult:
    LCDOUT $FE, $80, "Time Elapsed"
    LCDOUT $FE,$C0, dec2 Seconds, ".", dec2 Hundredths, ":", dec Thousandths
    If ButStart = 1 Then goto StartTimer
    If ButReset = 1 Then goto ResetTimer
    goto DisplayResult


    'SUBROUTINES
    '===========
    'Get value from Timer1 Register
    '------------------------------
    GetValue:
    Timer1H=TMR1H
    Timer1L=TMR1L
    Return

    'Reset Timer1 Register to Start from 1ms interval
    '-----------------------------------------
    SetReg:
    TMR1H = $FC
    TMR1L = $18
    Return

    Now, what is wrong with my codes? Correct me please.
    Last edited by sycluap; - 14th January 2008 at 02:47.

Similar Threads

  1. Software PWM using Timer1
    By muqasim in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th December 2009, 11:49
  2. Help with TIMER1 + SLEEP
    By Yodoad in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 22nd May 2009, 15:07
  3. Time Period of Timer1
    By arnol34 in forum mel PIC BASIC Pro
    Replies: 3
    Last Post: - 4th May 2007, 00:31
  4. continious counting process (capture)
    By asynch in forum General
    Replies: 1
    Last Post: - 17th February 2006, 07:42
  5. Timer1 and Interupt wierdness
    By mind in forum mel PIC BASIC Pro
    Replies: 0
    Last Post: - 23rd August 2005, 01: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