/*
 * Copyright(C) Paul und Scherer (mct.de/mct.net)
 *
 * This example demonstrates how to...
 *
 *  ... use a timer to trigger periodic
 *      events with no interrupt active.
 */

#include <target.h>

/*
 * Timer1 is initialized to count down to zero in
 * 500 milliseconds, periodically.
 *
 * The PLA is configured to toggle P4.2 (=LED) on
 * t1 counter underflow. This makes the LED blink
 * at intervals of 1 second (50% duty cycle).
 *
 * No interrupt is needed for this action.
 */
int
main(void)
{
	Intern_t1ld     = _CCLK/2;		// set load to 500ms
	Intern_gp4con  |= 0x300;		// configure PLA
	Intern_plaelm10 = 0x246;		//  to toggle P4.2
	Intern_placlk   = 0x50;			//  on t1 counter underflow
	Intern_t1con    = 0xc0;			// periodic @cclk

	return 0;
}
