/********************************************************************
	pwm_test.c
	Z-World, 2002

	Description
	===========
	This program demonstrates the PWM functions of the Rabbit 3000
	processor.
	
	It will set the four PWM channels, port F bits 4 - 7, to the
	following values:
	
	(PF4)	Channel 0:	10% duty cycle
	(PF5)	Channel 1:	25% duty cycle
	(PF6)	Channel 2:	50% duty cycle
	(PF7)	Channel 3:	99% duty cycle

	Pulse spreading can be turned on or off by 
	TEST_PWM_OPTIONS below. See documentation for
	pwm_set() for details.

	Instructions
	============
	1. Compile and run this program.
	2. Best way to view duty cycles is to observe each channel
	   with an oscilloscope. 

*********************************************************************/


main()
{
	unsigned long	freq;
	int	pwm_options;
	
	// request 10kHz PWM cycle (will select closest possible value)
	freq = pwm_init(10000ul);
	printf("Actual PWM frequency = %lu Hz\n", freq);

	pwm_options = 0;

	/*
 	Uncomment the following line to spread the PWM output
   throughout the cycle.
   */
//	pwm_options = PWM_SPREAD;

	pwm_set(0, 0.10 * 1024, pwm_options);
	pwm_set(1, 0.25 * 1024, pwm_options);
	pwm_set(2, 0.50 * 1024, pwm_options);
	pwm_set(3, 0.99 * 1024, pwm_options);
	while(1); //keep running the program		
}
