RTC via TMR0 + HSERIN and 16F916


Closed Thread
Results 1 to 6 of 6

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Timer 0 doesn't overflow 15 times per second...
    Timer 0 overflows 15.2587890625 times per second.
    15.2587890625 * 4 = 61.03515625
    61.03515625 - 60 = 1.03515625 minutes in error.
    That accounts for 1 minutes of error.
    I think it would be fairly reasonable to say that another 1% or so could possibly be accounted for with the resonator, and maybe another fraction could be accounted for by using a stopwatch and watching an LED.

    Do a search on the Olympic Timer here.
    Either that or you could keep track of the extra .2587890625 ticks per second in different variables and add them into the 'ticks' variable as appropriate...
    Code:
    subtick var word
    .......
    ......
    disable
    intManagement:
    if (INTCON.2 == 1) then
    subtick=subtick + 2587
    if subtick => 10000 then
    subtick=subtick-10000
    ticks=ticks+1
    endif
    ticks = ticks + 1 ' Count pieces of seconds
    ..............
    ticks = ticks - 15 (ticks = 0) 'One second elasped - update time <-just in case you miss one somewhere, don't zero it, just subtract 15
    ........
    .......
    That just might take care of .2587 of the .258790625 of the error.

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


    Did you find this post helpful? Yes | No

    Default

    AND you have to add the ON INTERRUPT latency

    Darrel's Elapsed timer? Why not? Or at very least DT Interrupts!
    Steve

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

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    AND you have to add the ON INTERRUPT latency
    But in this case, latency shouldn't really matter, 'cause the interrupt stubs isn't going to take anywhere near the total period of the interrupt (well, shouldn't anyways), T0 isn't being stopped by anything...

    And yes, DT's INTs and Elapsed Timer...always a good plan...

  4. #4
    Join Date
    Jan 2007
    Posts
    39


    Did you find this post helpful? Yes | No

    Default OPTION_REG = $d5 and ticks => 61

    Hello Skimask,
    thanks a lot for your help, I see.
    I am thinking that the easyest way to solve my problem is to use

    OPTION_REG = $d5

    disable
    intManagement:
    if (INTCON.2 == 1) then
    ticks = ticks + 1 ' Count pieces of seconds
    If ticks >= 61 Then
    if (ACTIVITY_LED == 1) then
    low ACTIVITY_LED
    else
    high ACTIVITY_LED
    endif
    ticks = 0 'One second elasped - update time
    manageIntSecond = 1
    endif
    INTCON.2 = 0
    endif
    INTCON.7 = 1
    resume

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    All other things being equal, that would give you roughly 49-50 seconds of slow error per day. Add one second every half hour, and you'll practically be dead on.

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