`Chapman
`
`115
`
`(11] Patent Number:
`[45] Date of Patent:
`
`4,903,251
`Feb. 20, 1990
`
`[54] ACCURACY ADJUSTMENT FOR
`TIME-OF-DAY CLOCK USING A
`MICROCONTROLLER
`
`4,513,259 4/1985 Frerking vccsssssssssssssssseen 331/176
`
`4,644,484 2/1987 Flynn et al..
`va 368/200
`4,708,491 11/1987 Lute sssccsssssosssccensesecenseeee 368/156
`
`[75]
`
`Inventor: Max C. Chapman, Plymouth, Mich.
`
`[73] Assignee:
`
`Ford Motor Company, Dearborn,
`Mich.
`
`Primary Examiner—Vit W. Miska
`Attorney, Agent, or Firm—Mark L. Mollon; Paul K.
`Godwin
`
`(21] Appl. No:: 402,726
`[22] Filed:
`Sep. 5, 1989
`
`[S21] Unt, CU occ.cceeceeseees G04C 13/08; GO4B 17/12
`[52] U.S. Cl. v..scecssscsssscetececcssecatersrses 368/156; 368/200
`[58] Field of Search .............cccsccssscseeeee 368/155-157,
`368/200-202; 364/569; 331/47, 66, 176
`
`[56]
`
`References Cited
`U.S. PATENT DOCUMENTS
`
`8/1981 Lowdenslageretal............ 368/200
`4,282,595
`3/1982 Gomi etal. ...........08 we. 368/202
`4,321,698
`4,407,589 10/1983 Davidsonetal. ...
`se 368/200
`5/1984 Vail ........ccsscorssoneeeee
`weve 368/202
`4,448,543
`
`4,502,790 3/1985 Yokoyama .......ssssssseesere 368/200
`
`
`
`[57]
`
`ABSTRACT
`
`A microcontroller, software-based time-of-day clock
`compensates for inaccurate oscillator frequency by
`periodically correcting the time-of-day value using a
`calibration offset measured by manufacturing test
`equipment and permanently stored in nonvolatile mem-
`ory. A high degree of time keeping accuracy is
`achieved without the use of trimming capacitors or
`presorted piezoelectric crystals in the oscillator. Fur-
`thermore, frequency error compensation is incorpo-
`rated into the microcontroller system without requiring
`a significant amount of processing time overhead.
`
`11 Claims, 3 Drawing Sheets
`
`FROM
`OSCILLATOR11
`
`COUNT DOWN
`REGISTER
`FOR
`ONE MILLION
`INTERVAL
`
`REGISTER
`
`COUNT DOWN
`REGISTER
`FOR
`ONE MINUTE
`INTERVAL
`
`RELOAD
`VALUE
`
`TIME
`
`TIME-OF-DAY
`VALUES
`
`1
`
`~
`
`APPLE 1031
`
`1
`
`APPLE 1031
`
`
`
`
`
`US. Patent—Feb. 20, 1990 Sheet1 of 3 4,903,251
`
`
`
`
`
`FROM
`OSCILLATOR11
`me rs eei a ee ee ee es ee ee De ee
`ee ee ree se ee
`
`lo
`
`
`
`
`COUNT DOWN
`RELOAD
`COUNT DOWN |
`REGISTER
`VALUE
`REGISTER
`
`
`FOR
`REGISTER
`FOR
`
`
`ONE MINUTE
`ONEMILLION
`
`INTERVAL
`INTERVAL
`
`
`
`
`
`
`
`
`
` |
`
`
`
`TIME-OF-DAY
`VALUES
`|
`
`
`EEPROM
`
`2
`
`
`
`U.S. Patent
`
`Feb. 20, 1990
`
`Sheet 2 of 3
`
`4,903,251
`
`ENTER TIMER
`INTERRUPT SERVICE
`ROUTINE
`
`40
`
`DECREMENT THE
`ONE MILLION
`INTERRUPTS
`COUNTER
`
`44
`
`
`a>YES
`
`RELOAD THE
`ONE MILLION
`INTERRUPTS
`COUNTER WITH
`1,000,000
`
`
`
`SET THE ONE
`MINUTE INTERVAL
`COUNTER RELOAD
`VALUE TO 6144
`+/- PPM ERROR
`
`as
`
`
`
`4\
`
`
`
`INCREMENT THE
`
`
`TIME-OF-DAY
`
`
`MINUTES VALUE
`
`
`
`
`
`DECREMENTTHE
`ONE MINUTE
`INTERVAL
`COUNTER
`
`
`
`
`
`RELOAD THE
`ONE MINUTE
`INTERVAL
`
`COUNTER WITH
`
`RELOAD VALUE
`
`
`
`
`INCREMENT THE
`SET THE ONE
`
`TIME-OF-DAY
`MINUTE INTERVAL
`
`
`HOURS VALUE
`COUNTER RELOAD
`
`
`VALUE TO 6144
`
`
`
`TO "01"
`
`RESET THE
`HOURS VALUE
`
`FIG.3
`
`3
`
`
`
`
`
`US. Patent—Feb. 20, 1990 Sheet 3 of 3 4,903,251
`
`
`
`COMPUTER
`
`TEST
`
`FREQUENCY
`COUNTER
`
`FIG.4
`
`4
`
`
`
`1
`
`4,903,251
`
`ACCURACY ADJUSTMENT FOR TIME-OF-DAY
`CLOCK USING A MICROCONTROLLER
`
`BACKGROUND OF THE INVENTION
`
`5
`
`2
`intervals of the interrupts themselves are error cor-
`rected.
`The ability to change the period between interrupt
`signals is essential to the technique disclosed in Luitje.
`However,not all microcontrollers provide user access
`to the interrupt interval. For example,
`the COP888
`family of microcontrollers manufactured by National
`Semiconductor Corporation use an idle timer for pro-
`viding a time base. Theidle timeris a free-running 16-bit
`timer which is clocked from the crystal oscillator via a
`divide-by-10 circuit. Whenever the 12th bit toggles its
`value, an interrupt is generated by the idle timer which
`can be used to update various time-of-day counters. The
`period between these interrupts is not programmable
`and depends only uponoscillator frequency. Therefore,
`the technique described in Luitje cannot be used. Fur-
`thermore, the calculations required to apply error cor-
`rection to the programmable register value and the need
`to correct for inaccuracies each and every second in-
`creases the processor overhead associated with use of
`the Luitje technique to an undesirable level.
`SUMMARYOF THE INVENTION
`
`The present invention relates in general to a time-of-
`day clock implemented using a microcontroller, and
`more specifically to correcting for time keeping inaccu-
`racies resulting from frequencyerrorsof a crystal oscil-
`lator.
`Microprocessor and microcontroller systems operate
`using internal timing circuits for coordinating process-
`ing operations and establishing machine timing cycles
`for execution of instructions. A crystal oscillator is
`frequently employed to provide timing signals for the
`microprocessor due to therelatively high accuracy and
`stability of piezoelectric crystals.
`One of the functions that is often performed using a
`microprocessor or microcontroller is that of a time-of-
`day clock. Such a clock is implemented using time val-
`ues stored in memory which are updated periodically
`by the microprocessor. which counts timing signals
`received from the crystal oscillator. Typically, the time-
`It is a principal object of the present invention to
`of-day function is incidental to some other primary
`improve time-of-day clock accuracy for a microcon-
`control
`function being implemented using the mi-
`troller software-based clock in an inexpensive manner.
`crocontroller, such as control of an automotive audio
`It is another object of the present invention to pro-
`system. Proper operation of that primary control func-
`vide a method and apparatus for correcting for time-of-
`tion is not highly dependent upon the accuracy of the
`day inaccuracies resulting from the use of unmatched,
`internal clock whichis driven by the piezoelectric crys-
`unsorted components in a crystal oscillator.
`tal oscillator. However, in implementing a time-of-day
`It is a further object of the invention to reduce mi-
`clock using the microcontroller, a crystal oscillator
`crocomputer processing time overhead associated with
`error amounting to even a few parts per million causes
`correction of time-of-day measurement.
`a significant timing error to eventually be accumulated
`These and other objects are achieved in an apparatus
`in the time-of-day clock.
`,
`.
`comprising idle timer means for generating interrupts
`Typical manufacture of piezoelectric crystals results
`separated by a fixed time period which differs from an
`in a variability of the crystal’s resonant frequency of
`ideal time period by an error. First counting means are |
`about 20 parts per million (ppm). In order microcon-
`coupled to the idle timer means and havea first register
`troller time-of-day clocks, crystals can be presorted into
`for counting the interrupts and for generating an incre-
`various. value ranges by the crystal manufacturer and
`ment signal when a numberofinterrupts have occurred
`subsequently matched with particular values of load
`equal to a load value which is loadedinto the first regis-
`capacitors for constructing each individual crystal os-
`ter. Reload means are coupled to the first counting
`cillator. Such sorting and matching of components in-
`means for storing a reload value and for (1) transferring
`creases the cost of the clock.
`the reload value to the first register as the load value
`Another method for obtaining accurate oscillator
`upon the occurrence of the increment signal and (2)
`signals is to provide a variable load capacitor to allow
`then resetting the reload value to a predetermined
`adjustment(i.e., trimming) of the oscillator frequency.
`value. Second counting means are coupled to the idle
`However, the variable capacitor and the need for man-
`timer means and to the reload means for counting the
`ual calibration add expense to the oscillator.
`interrupts and for transfering an adjusted reload value
`It is preferable to manufacture an oscillator using
`including an accumulated error value to the reload
`unmatched, standard tolerance components without
`means as the reload value when a numberofinterrupts
`special trimming capacitors. Therefore, there have been
`have occurred equal to a large count numberrelatively
`attempts to allow the oscillator to run at an incorrect
`greater than the predetermined value. Time means are
`frequency, measure the frequency error, and compen-
`coupled to the first counting means and receives the
`sate for the error within the microcontroller as it keeps
`incrementsignal for keeping track of time-of-day. Pref-
`track of time-of-day. For example, Luitje (U.S. Pat. No.
`erably,
`the apparatus further comprises nonvolatile
`4,708,491), discloses an untrimmed crystal circuit con-
`storage means coupled to the reload means for storing
`the accumulated error value or the adjusted reload
`nected to the oscillator of a microcomputer. After fre-
`value. The accumulated error value is substantially
`quency prescaling,
`the timing signal is measured to
`determine an error value. A correction term is stored in
`equal to the algebraic sum of the predetermined value
`(ie., normal reload value) and the quantity resuiting
`the microcomputer via entry from a keyboard. During
`from the time period error times the large count number
`clock operation, the value in a free-running counter is
`divided by the ideal time period.
`compared to a programmable register. Interrupts are
`Theinvention also provides a method for maintaining
`generated when the numberin the programmableregis-
`ter equals the numberin the free-running counter. The
`accurate time keeping with an interrupt-driven clock,
`the interrupts being separated by a fixed time period.
`interrupts provide a time base for keeping track of time-
`The method includes the steps of maintaining a first
`of-day. The correction term is used in loading the pro-
`grammabie register once each second so that the time
`countof interrupts correspondingtoafirst time interval
`
`10
`
`_—5
`
`35
`
`40
`
`60
`
`65
`
`5
`
`
`
`s
`
`4,903,251
`
`20
`
`4
`being measured and displayed by the clock. Time values
`example will be presented throughout this description
`in which crystal 12 resonates at a frequency of 4.194304
`for display are maintained by the clock. A second count
`MHz. Thus, the period of the oscillator signals equals
`of interrupts is maintained corresponding to a second
`about 0.2384186 microseconds, and the output of the
`time interval equaling a large numberofinterrupts and
`divide-by-10 circuit has a period of about 2.384186 mi-
`containing many ofthefirst time intervals. In response
`croseconds. Theidle timer counts 4096 of these signals,
`to the first count being equal to the predetermined num-
`which ideally yields 9765.625 microseconds between
`ber, the steps are performed of (A)restarting the first
`interrupts. Counting 6144 of the idle timer interrupts
`count to count to the predetermined number; (B) updat-
`yields a measurementperiod of exactly one minuteif the
`ing the time values; and (C) setting the predetermined
`crystal resonant frequency is completely accurate. By
`numberto a first constant equaling the numberofinter-
`keeping track of the idle timer interrupts, calculating
`rupts that would occur during the first time interval if
`real time minutes and hours is a straightforward matter
`the time between interrupts equaled an ideal time per-
`for the microcontroller software. However, due to the
`iod. In response to the second count being equal to the
`nonideal resonant characteristic of piezoelectric crystal
`large number, the steps are performed of (A)restarting
`12, the actual real time between counts of 6144 inter-
`the second count; and (B) setting the predetermined
`number to a second constant related to the difference
`rupts differs from one minute by someerror. According
`to the presentinvention,the error is allowed to accumu-
`between the fixed time period and theideal time period
`late for some period of time, followed by a correction
`multiplied by the large number and divided by the ideal
`based. upon a measurementofthe error.
`time period.
`FIG. 2 shows one preferred implementation of the
`BRIEF DESCRIPTION OF THE DRAWINGS
`present invention as embodied in microcontroller 10. A
`The novel features of the invention are set forth with
`system clock 25 receives an oscillator signal from crys-
`tal oscillator 11. System clock 25 performs the divide-
`particularity in the appended claims. The invention
`by-10 function and provides a system clock signal to
`itself, however, both as to its organization and method
`idle timer 26. Idle timer 26 in the preferred embodiment
`of operation, together with further objects and advan-
`is comprised of a free-running 16-bit timer which is
`tages thereof, may best be understood by reference to
`tapped at its 12th bit to generate an interrupt when the
`the following description taken in conjunction with the
`12th bit changes its value, i.¢., each 4096th system clock
`accompanying drawings, in which:
`pulse. The interrupt output from idle timer 26 is con-
`FIG.1 is a schematic, block diagram illustrating the
`nected to a countdown register 27 and a countdown
`overall system used in the present invention.
`register 28. Countdown register 27 has an output cou-
`FIG.2 is a block diagram illustrating apparatus ac-
`pled to a reload means 30 and to time-of-day values
`cording to the present invention.
`store 33. Countdown register 28 has an output con-
`FIG.3 is a flowchart illustrating a preferred method
`nected to an add and save means 35. Add and save
`according to the present invention.
`means 35 has an output connected to reload means 30
`FIG.4 is a schematic, block diagram illustrating ap-
`and has an input connected to an electrically erasable
`paratus for measuring an oscillator frequency error and
`programmable read only memory (EEPROM) 34.
`for storing a correction value for accurate time keeping
`Countdownregisters 27 and 28 each hasaresetline for
`by a microcontroller.
`reinitiating a count once zero has been reached in the
`DETAILED DESCRIPTION OF PREFERRED
`previous countdown sequence.
`EMBODIMENTS
`Reload means 30 includes a reload value register 31
`and a first constant storage portion 32. Storage portion
`32 stores the number 6144 which is the count number
`correspondingto the ideal performanceof crystal oscil-
`lator 11. EEPROM 34 contains an error value which
`correspondsto the parts per million error in the crystal
`oscillator frequency. This error is algebraically added
`to 6144 and the result is stored in add and save means35.
`Alternatively, the result of the addition could itself be
`stored in EEPROM 34, but this would require two
`bytes of EEPROM storage.
`In operation, countdown register 27 counts idle timer
`interrupts corresponding to a one minute interval.
`When countdown register 27 reaches zero, an incre-
`ment signal is sent to time-of-day values 33 in order to
`update the values to reflect that a minute has expired. A
`reload value in reload value register 31 is loaded into
`countdown register 27 which is then reset to initiate a
`countdown from the loaded value. The incrementsig-
`nal from countdown register 27 is also connected to
`teload means 30 in order to cause the transfer of the
`predetermined constant 6144 from storage portion 32 to
`reload value register 31. Thus, reload value register 31
`most often contains 6144 and the value loaded into
`countdown register 27 is usually the number corre-
`sponding to ideal operation of the crystal oscillator.
`As a means for correcting the accumulated error in
`the interrupt signal from idle timer 26, the interrupts are
`
`Referring to FIG. 1, a microcontroller 10 is con-
`nected to a crystal oscillator 11. In the illustrated em-
`bodiment, microcontroller
`10
`is comprised of a
`COP888CG microcontroller manufactured by National
`Semiconductor Corporation.
`Oscillator 11 includes a piezcelectric crystal 12 con-
`nected to terminals CKI and CKO of microcontroller
`10. A resistor 13 is connected across crystal 12. A fixed
`capacitor 14 couples one end ofpiezoelectric crystal 12
`to ground 16. A fixed capacitor 15 couples the other end
`of crystal 12 to ground 16.
`On microcontroller 10, a terminal 17 is connected to
`a supply voltage V.., preferably in the range of from
`4-6 volts DC. The time values maintained by microcon-
`troller 10 are provided via 1/O lines 18 to a display
`driver 20 which controls a display 21.
`A set of input switches 22 are coupled to microcon-
`troller 19 via I/O lines 19 for allowing the setting of the
`time values by selective activation of the switches. For
`example, input switches 22 may be comprised of a key-
`pad matrix for activating separate interrupt signals to
`microcontroiler 10.
`Microcontroller 10 includes an idle timer which re-
`ceives timing signals from oscillator 11 via a divide-by-
`10 circuit (not shown). The idle timer countsthe signals
`received from the divide-by-10 circuit and generates an
`interrupt upon each count of 2!2 or 4096. A numerical
`
`30
`
`40
`
`45
`
`50
`
`60
`
`65
`
`6
`
`
`
`5
`counted down in countdownregister 28 from a large
`numbersuch as 1,000,000. The premeasurederrorof the
`crystal oscillator stored in EEPROMis in units of parts
`per million. This number is added to 6144 in block 5.
`When the countdown from the one million interval
`expires, the modified one minuteinterval count derived
`from adding the parts per million error to 6144 is loaded
`into reload value register 31. The modified value is
`guaranteed ofbeing used onetime sincethe usual value
`of 6144 will only replace the modified value after the
`next reload of countdownregister 27 occurs.
`The present invention performs correction for time
`keeping inaccuracy only after some amount of error has
`been allowed to accumulate. Therefore, processing time
`overhead associated with the time correction is mini-
`mized. For example, if.a crystal oscillator had a +100
`ppm error (which is five times greater than standard
`crystal
`tolerance), a 1.6% slower or faster minute
`would occur every 2.7 hours upon the counting down
`of the onemillion interval. Such an altered minuteis not
`perceptible to the user of the clock, but overall accu-
`racy of the clock is maintained.
`EEPROM 34 is selected for storing the parts per
`million accumulated error value in order to provide
`nonvolatile storage of the correction factor so that it is
`not lost when power is removed from the microcon-
`troller system. In determining an accumulated error
`value A, measurements are made to determine the dif-
`ference between the actual fixed time period between
`interrupts from idle timer 26 and the ideal time period
`which would result from a crystal oscillator operating
`exactly at the designed frequency. In the present exam-
`ple, the ideal time period is 2.384186 microseconds. The
`time difference error (i.e., actual minus ideal) is multi-
`plied by 1,000,000 and divided by the ideal time period
`to derive the accumulated error value A in parts per
`million. Some number other than 1,000,000 could be
`used as long as it were larger than the one minute inter-
`val and preferably contained many one minute intervals
`to obtain the benefits of reduced processor loading and
`greater resolution of adjustment accuracy.
`.
`FIG. 3 shows a flowchart for a preferred software
`embodiment according to the present invention. Upon
`receiving an interrupt from the idle timer, a timer inter-
`rupt service routine is entered in step 40. In step 41, the
`one minute interval counter is decremented by one. In
`step 42, a test is made to determine whether the decre-
`mented one minute interval counter contains a value
`greater than zero.If the value is greater than zero, step
`43 is executed, otherwise step 46 is executed.
`In step 46, the one minute interval counter is reloaded
`with the reload value. The one minute interval counter
`reload value is set to 6144 in step 47. In step 48, the
`time-of-day minutes value is incremented. Ifthe minutes —
`value is less than 60 after incrementing, step 49 proceeds
`to step 43, otherwise step 50 is executed. In step 50, the
`minutes value is reset to “00”. In step 51, the time-of-
`day hours value is incremented by one. In step 52, the
`hours valueis tested to determine whetheritis less than
`13 and,if so, step 43 is executed, otherwise the hours
`value is reset to “O01” at step 53 before proceeding to step
`43.
`Tn step 43, the one million interrupts counter is decre-
`mented by one. In step 44, the one million interrupts
`counter value is checked for a value greater than zero.
`If the numberis greater than zero, a return from the
`timerinterrupt service routine is madein step 45. Other-
`wise, the one million interrupts counteris reloaded with
`
`50
`
`65
`
`4,903,251
`
`40
`
`45
`
`6
`the number 1,000,000 at step 55. In step 56, the one
`minute interval counter reload value is set to the value
`of 6144 plus the parts per million accumulated error,
`then a return is made from the timer interrupt service
`routine in step 45.
`Turning to FIG.4, an electronic system 60, such as a
`microprocessor-controlled audio system,
`including a
`time-of-day. clock,
`is connected to a production test
`device 61. Microcontroller 10 includes crystal oscillator
`11 and EEPROM 34 as previously described. Mi-
`crocontroiler 10 further includes a universal asynchro-
`nous receiver/transmitter (JART) 62 and a data output
`terminal which provides a test point 63. Test device 61
`includes a test computer 65 and a high accuracy fre-
`quency counter 67. Test computer 65 is coupled to
`frequency counter 67 and further includes a UART 66
`coupled to UART 62 via communication link 70. Fre-
`quency counter 67 includes an input line 72 connected
`to a test probe 71 which in turn is connected to test
`point 63 for purposes of testing the operation of elec-
`tronic system 60.
`In operation, during production testing of electronic
`system 60, test computer 65 instructs microcontroller 10
`throughlink 70 to output a test signal at its data terminal
`connected to test point 63. The test signal is propor-
`tional to the interrupt period of the microcontrolleridle
`timer. The test signal is measured by frequency counter
`67 via test probe 71. Test computer 65 receives the
`actual frequency measurement from frequency counter
`67 and calculates the oscillator frequency error in parts
`per million. The parts per million error value can be
`either positive or negative and is transmitted via the
`UARTinterface to microcontroller 10 which stores the
`error value in EEPROM 34. For example, the error
`value may be an 8-bit number stored in two’s comple-
`ment format when negative. The 8-bit error value can
`represent correction factors within a range of +127
`ppm which is adequate for standard oscillator circuit
`components. Since the calibration or test signal gener-
`ated by microcontroller 10 is generated only during
`production testing, interference of the test signal with
`audio signals or other signals within electronic system
`60 during normal operation is avoided. Furthermore,
`the correction factor determination is fully automated
`and can be integrated with the normal productiontest-
`ing performed on electronic system 60. Therefore, no
`significant added expense is realized in providing accu-
`rate time keeping.
`While preferred embodiments of the invention have
`been shown and described herein, it will be understood
`that such embodiments are provided by way of example
`only. Numerousvariations, changes, and substitutions
`will occur to those skilled in the art without departing
`from the spirit of the invention. Accordingly, it is in-
`tended that the appended claims coverall’ such varia-
`tions as fall within the spirit and scope of the invention.
`Whatis claimed is:
`:
`1. Apparatus comprising:
`idle timer means for generating interrupts separated
`by a fixed time period which differs from an ideal
`time period by an error;
`first counting means having a first register and cou-
`pled to said idle timer means for counting said
`interrupts and for generating an increment signal
`when a numberof interrupts have occurred equal
`to a load value loaded into said first register;
`reload means for storing a reload value and for (1)
`transferring said reload valueto saidfirst register as
`
`7
`
`
`
`4,903,251
`
`7
`said load value upon the occurrenceofsaid incre-
`ment signal and 2) then resetting said reload value
`to a predetermined value;
`second counting means coupled to said idle timer
`means and to said reload means for counting said
`interrupts and for
`transferring an accumulated
`error value to said reload means as said reload
`value when a number of interrupts have occurred
`‘equal to a large count numberrelatively greater
`than said predetermined value; and
`time means coupledto said first counting means and
`receiving said incrementsignal for keeping track of
`time-of-day.
`2, The apparatus of claim 1 further comprising:
`non-volatile storage means coupled to said reload
`means for storing said accumulated error value,
`said accumulated error value being substantially
`equal to the sum of said predetermined value and
`the quantity of said error times said large count
`number divided by said ideal time period.
`3. The apparatus of claim 1 further comprising:
`non-volatile storage means for storing an offset value;
`and
`adding means coupled to said non-volatile storage
`means and to said reload means for adding said
`offset value and said predetermined value to obtain
`said accumulated error value, said offset value
`being substantially equal to said error times said
`large count numberdivided by said ideal time per-
`iod.
`4. The apparatus of claim 1 further comprising:
`test means coupled to said idle timer for causing said
`idle timer to produce a test signal for measuring
`said error.
`5. The apparatus of claim 1 wherein said first count-
`ing means, said second counting means, said idle timer
`means, said reload means, and said time means are im-
`plemented using a microcontroller, said apparatus fur-
`ther comprising a crystal oscillator coupled to said
`microcontroller.
`.
`6. The apparatus of claim 5 further comprising:
`interface means coupled to said microcontroller for
`interfacing said microcontroller to test equipment
`for measuring a test signal having a frequency de-
`pendent on said oscillator; and
`
`8
`non-volatile storage means coupled to said microcon-
`troller for storing a representation of said accumu-
`lated error value.
`7. The apparatus of claim 6 wherein said non-volatile
`storage means is comprised of an EEPROM.
`8. The apparatus of claim 5 further comprising a
`display means coupled to said time means for displaying
`time-of-day information.
`9, A method for. maintaining accurate time keeping
`with an interrupt-driven clock, said interrupts being
`separated by a fixed time period, said method compris-
`ing the steps of:
`maintaining a first count of interrupts corresponding
`to a first time interval being measured and dis-
`played by said clock;
`maintaining time values for display by said clock;
`maintaining a second count of interrupts correspond-
`ing to a second time interval equalling a large num-
`ber of interrupts and containing manyof said first
`time intervals;
`in responseto said first count being equal to a prede-
`termined number, performing the steps of (A) re-
`starting said first count to count to said predeter-
`mined number:(B) updating said time values; and
`(C) setting said predetermined numberto a first
`constant equalling the number of interrupts that
`would occur during said first time interval if the
`time between interrupts equalled an ideal time per-
`iod; and
`in response to said second count being equal to said
`large number, performing the steps of (A) restart-
`ing said second count; and (B)setting said predeter-
`mined number to a second constant related to the
`difference between said fixed time period and said
`ideal time period multiplied by said large number
`and divided by said ideal time period.
`10. The method of claim 9 wherein said first and
`second counts are maintained by counting down from
`said predetermined number and said large number, re-
`40 spectively, to zero.
`11. The method of claim 9 further comprising the
`steps of:
`determining the error betweensaid fixed time period
`and said ideal time period using test equipment;
`calculating said second constant; and
`storing a representation of said second constant in
`non-volatile memory associated with said clock.
`*
`*
`*
`*
`#
`
`45
`
`15
`
`25
`
`50
`
`55
`
`65
`
`8
`
`