Digital Hourmeter


Results 1 to 15 of 15

Threaded View

  1. #5
    Join Date
    Feb 2004
    Location
    Michigan, USA
    Posts
    305


    Did you find this post helpful? Yes | No

    Default

    SetTimer:
    T1CON.0=0 ' Stop the Clock
    TMR1RunOn.Highbyte=TMR1H ' Load the Run-On (Over-Run) value (if any)
    TMR1RunOn.Lowbyte=TMR1L
    TMR1RunOn=TMR1Preset+TMR1RunOn ' Calculate the New (adjusted) value for TMR1
    If TMR1CalAR=0 then ' Calibration ADVANCE (add) or RETARD (subtract)
    TMR1RunOn=TMR1RunOn+TMR1Cal
    else
    TMR1RunOn=TMR1RunOn-TMR1Cal
    endif
    TMR1H=TMR1RunOn.Highbyte ' Save new values to TMR1
    TMR1L=TMR1RunOn.Lowbyte
    T1CON.0=1 ' Restart the Clock
    PIR1.0=0 ' Reset TMR1's Interupt Flag
    Return


    Ok, code killing aside.... forgive my noobness.

    If I strip out the calibration aspect as I dont think i need it. (1sec/60hz = 1 pulse every 16.667ms) should be enough time.....


    SetTimer:
    T1CON.0=0 ' Stop the Clock
    TMR1.Highbyte=TMR1H ' Load the high timer start point
    TMR1.Lowbyte=TMR1L ' Load the low timer start point
    TMR1.Highbyte= $AB ' Save new values to TMR1 (65535 - 21600 = 43935 = AB9F)
    TMR1.Lowbyte= $9F
    T1CON.0=1 ' Restart the Clock
    PIR1.0=0 ' Reset TMR1's Interupt Flag
    Return


    This should reset the timer everytime with 43935 as a starting point, leaving 21600 pulses until a rollover and the interupt flag is set, upon which the program needs to increment a counter by 1, store the result in eeprom and reset the counter to start again. Oh, and increment the display aswell ;-)
    Last edited by jmgelba; - 12th April 2005 at 22:08.

Similar Threads

  1. Replies: 5
    Last Post: - 16th October 2009, 19:29
  2. Digital Out on an A/D pin safe ?
    By mr.sneezy in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 21st January 2009, 23:48
  3. analog and digital
    By lerameur in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 10th June 2008, 03:40
  4. Replies: 4
    Last Post: - 24th January 2007, 23:20
  5. Digital IC Tester
    By precision in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 18th September 2006, 04:38

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