This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

PWM code not running on LPC2129 board but working on logic analyzer .

#include<lpc214x.h>

int main()

{

PINSEL0=0x00000002; // P0.0 to P0.15 pins of PORT0 as GPIO

PINSEL1=0x00000000; // P0.21 Pin of PORT0 as PWM

PINSEL2=0x00000000; // P1.16 to P1.31 pins of PORT1 as GPIO

/*Configure the PLL block and set the CCLK and PCLK at 60 MHz */

//PLL0CON=0x01;

//PLL0CFG=0x25;

//PLL0FEED=0xaa;

//PLL0FEED=0x55;

//while (! (PLL0STAT & 0x00000400));

//PLL0CON=0x03;

//PLL0FEED=0xaa;

//PLL0FEED=0x55;

//VPBDIV=0x01;

/* Setup and initialize the PWM block */

PWMPCR=0x00; // Single Edge PWM Mode

PWMPR=0x00; // Resolution of PWM is set at 1 mS

PWMMR0=1000; // Period of PWM is 10 mS

PWMMR1=100; // Pulse width of PWM5 is 1 mS

PWMMCR= (1<<1); // PWMTC is reset on match with PWMMR0

PWMLER= (1<<1)| (1<<0); // Update Match Registers PWMMR0 and PWMMR1

PWMPCR= (1<<9); // Enable PWM1 output

PWMTCR= (1<<1); // Reset PWM TC and PWM PR

PWMTCR= (1<<0)| (1<<3); // Enable PWM Timer Counters and PWM Mode

while (1)

{

if (! ((IO0PIN) & (1<<15))) // Check for P0.15

{

PWMMR1 = 100;

PWMLER = (1<<1); //Update Latch Enable bit for PWMMR1

}

else if ( ! ((IO0PIN) & (1<<16))) // Check P0.16

{

PWMMR1 = 200;

PWMLER = (1<<1);

}

else if (! ((IO1PIN) & (1<<16)) ) // Check for P1.16

{

PWMMR5 = 400;

PWMLER = (1<<1);

}

else if (! ((IO1PIN) & (1<<17))) // Check for P1.17

{

PWMMR5 = 800;

PWMLER = (1<<1);

}

}

//return 0;

}

 

 

I am trying to generate PWM output on pin 19 or using PWM1.it works on logic analyzer but doesn't run on hardware.LED brightness is no changing nor LED lighting.Pls can I get a help.