Download library here.

Check the tutorial page for an explanation about PWM.


PWM



#include "lpc17xx.h"
#include "lpc_types.h"
#include "pwm.h"
#include "timer.h"

int main(void)
{
	PWM_Init(1,6,1000);										//Initialize PWM port 6
	PWM_Start(1);											//Start PWM

	TimerInit(0, 1000);										//Initialize timer 0

	int pwmoffset = 0;										//Declare pwmoffset as integer

    while(1)
    {
    	for (pwmoffset = 0; pwmoffset < 1000; ++pwmoffset)
    	{
    		PWM_Set(1,6,pwmoffset);							//Set PWM offset
    		delayMs(0,5);									//Delay 5 ms
		}

    	for (pwmoffset = 1000; pwmoffset > 0; --pwmoffset)
    	{
    		PWM_Set(1,6,pwmoffset);							//Set PWM offset
    		delayMs(0,5);									//Delay 5 ms
		}
   }
}

 




Copyright 2011. Joomla 1.7 templates - Joomla template maker. The Simplecortex is developed by BRC-Electronics