/*
	TOSHT1.C

   Sample program to control the output of pin TOUT on the Toshiba RTC (real-
   time-clock).

	TOUT (pin 12) on the Toshiba RTC TC8250P is controllable through register
	0x0d of the chip. The following configurations are possible:

            0        1 hz           50 % duty cycle
            1        2 hz                 "
            2        4 hz
            .
            .
            11       2048 hz              "
            12       1 min. pulse   Pulse width 30.5 us
                                    Positive pulse.
            13       10 min. pulse        "
            14       TOUT = VDD
            15       TOUT = VSS

	For minimum current drain on the battery, set TOUT = VSS. Make sure INT2
	is not enabled.

	To check these configurations, type "tosht0(xx)" in the watch window and
	observe the output of pin 12 with a multimeter (eg: FLUKE 79). This is rather
	difficult with the PK22xx/Little Star, as the 8250 is situated underneath
	the battery.
*/

#use "default.h"
#use cplc.lib

#if !(BOARD_TYPE==CPLC_BOARD || BOARD_TYPE==L_STAR)
#fatal "This program only runs on a PK21xx/Rugged Giant or a PK22xx/Little Star"
#endif

main()
{
    uplc_init();
    outport(ITC, inport(ITC) & '\B11111011'); // make sure INT2 is off
    tosht0(15);              // write 15 to RTC register 0xd
                             // this will make TOUT low.
    while (1) 
        runwatch();
}

