|
||
TIMEKEEPING
The TDS9092 maintains time and date through the above Forth words. Power must be applied to the board or the time and date will be lost, but a built-in mechanism described below allows you to use the low power 2 to 3mA mode and still maintain this function. For a completely non-volatile clock see the section NON-VOLATILE CLOCKS. When power is first applied, the time is set to 00.00.00 and the date to 1.01.84. An interrupt is already set up which causes this time and date to increment. The correct time and date can now be set with NOW and HRS . For example, at 9pm on Christmas evening:
25.12.95 NOW 21.00.00 HRS
The date and time can be sent to the serial link with .DATE and .TIME and by re-vectoring EMIT they can be written to an LCD, sent to the serial port, or output in any other way. Other words provided allow other formats for date and time which are used in USA and other countries. For example:
: .USADATE @DATE >DMY >R 2 U.R "/ EMIT 2 U.R "/ EMIT R> 2 U.R ;
This outputs the above date as 12/25/95 instead of 25.12.95. The dates computed adjust automatically for leap years. The raw data which the Forth words use are in the 3 variables TICKS MINS DAYS . These can be accessed directly to give special functions. The clock works using the Timer 1 Overflow Interrupt. Every 53.333ms this interrupt increment the ticks register, and each minute resets it and increments the minutes register. Once per day the minutes register is reset and the day register is incremented. The words shown above work with these three variables. The interrupt is written in machine code and only takes 40�s every 53ms. This represents less than an 0.08% overhead but it can be eliminated with -TIMER . When the low power operational mode is used, the microprocessor is in standby most of the time and the interrupt does not work; only a reset will take the microprocessor out of standby. However, when the watchdog timer restarts the microprocessor, it gives two increments to the ticks register. The watchdog time period is exactly twice the usual interrupt repetition rate so the correct time is maintained. See the section LOW POWER OPERATION for more details of this mode. Some care is necessary when using the low power mode:
q No word which resets the watchdog timer should be used in the sequence the machine will usually take from watchdog reset to standby. For this reason the word IF does not service the watchdog. Remember that looping words such as BEGIN DO +LOOP etc. all reset the watchdog. q If the machine is allowed to power up, through pressing a matrix key, for example (to take the case shown in the LOW POWER OPERATION section), then keep it up for a significant time, say 10 seconds at least. This will minimise the effect of the possible loss of a few microcycles at the transition between the interrupt and watchdog timekeeping mechanisms. Keep the transitions as low as feasible. Each gives accurate timekeeping but transitions may slow the clock a fraction. |