Pages

Thursday, 26 April 2018

ARM-LPC1768-Using the Internal PWM module of ARM controller, generate PWM and vary its duty cycle


Program:
/**
  * @brief Generate PWM on P2.0
  * DutyCycle varies from 0-100% and back from 100%- 0%.
  */

#include <lpc17xx.h>
#include "pwm.h"

/* variable to hold dutycycle value */
uint8_t dutyCycle;

int main(void)
{
/* Initialize the PWM Peripheral */
  PWM_Init();

/* Infinite loop */
while(1)
{
/* Increase dutycycle for from 0 to 100% */
for(dutyCycle = 0; dutyCycle < 100; dutyCycle++)
{
/* Set the PWM */
PWM_Set_Duty(dutyCycle);

/* set delay */
DELAY_ms(5);
}

for(dutyCycle = 100; dutyCycle > 0; dutyCycle--)
{
/* Set the PWM */
PWM_Set_Duty(dutyCycle);
/* set delay */
DELAY_ms(5);
}
}
}

Hardware Connections:
Connect positive of the CRO to pin P2.0
Connect negative of the CRO to the GND (development board)

Output:
A square wave is seen on CRO who pulse width varies from 0% - 100% and from 100% - 0%

 FOR DETAIL INFORMATION ABOUT ARM CORTEX DEVELOPMENT KIT : CLICK HERE

No comments:

Post a Comment