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

PROBLEM IN PWM PULSES IN ARM LPC2148

HI EVRYBODY,,, i am new to arm.i m getting pwm 3 pulses at the respected pin no on cro. Now i want to use pwm 1 to pwm 6 at the same time. But not getting how to generate all the pwm pulses. Can antbody suggest how to do it? or modification in following code. the below code is work only for pwm3.

plz help

#include <LPC214X.H> // LPC21XX Peripheral Registers

void __irq PWMISR(void);
void PWMInit (void);
void delay (void);

//End of Declarations**********************
/*****************************************/
/*****************************************/
//Main Function****************************
int main (void)
{

PINSEL0 = 0x8; //Select P0.1 as PWM3 IO1DIR = (1<<19) | (1<<18) | (1<<17) | (1<<16); PINSEL2 = 0x00000000;

PWMInit (); //Jump to PWM initialize

while(1) //Infinite loop {

}
}

/*****************************************/
/*****************************************/
//Start of Timer initialization************

void PWMInit (void) //Timer initialize function
{

PWMTC = 0x0; //Set the Timer Counter to start counting from zero PWMPR = 0x1;

//Maximum value of the Prescaler PWMPC = 0x0; //Sets the prescaler division of the PCLK. Start counting at zero

/* Prescale Counter is incremented on every PCLK. When it reaches the value stored in the PWM Prescale Register, the PWM Timer Counter is incremented and the PWM Prescale Counter is reset on the next PCLK. This causes the PWM TC to increment on every PCLK when PWMPR = 0, every 2 PCLKs when PWMPR = 1, etc. */

//PWMMCR = 0x00000003;//On match with timer reset the counter PWMMCR = 0x00000600;//On match with timer reset the counter

//PWMMR0 = 0x0ff; //Set the match register PWMMR1 = 0x088; //Set the match register PWMMCR = 0x2; //Reset timer counter on match

PWMMR3 = 0x000f;//0x0ff; //Set the match register PWMMR1 = 0x088; //Set the match register PWMMCR = 0x2; //Reset timer counter on match

//PWMPCR = 0x001; //Enable PWM1 output //PWMPCR = 0x008; //Enable PWM3 output //PWMPR = 0x00000001; //Load prescaler //PWMPR = 0x00000001; //Load prescaler PWMPR = 0x00000008;//0x00000008; //Load prescaler

PWMTCR = 0x00000002;//Reset counter and prescaler //PWMTCR = 0x00000009;//enable counter and PWM, // release counter from reset PWMTCR = 0x00000009;//enable counter and PWM, //release counter from reset

//PWMLER = 0x08; //PWMPCR = 0X0100; PWMPCR = 0X0800;

PWMTCR = 0x9; // Enable (sart) PWM Note Match registers must be set prior to enable. Turn on Timer counter and Prescaler

PWMLER = 0x08;

VICIntSelect = 0x00000000; // Setting all interrupts as IRQ(Vectored) VICVectCntl0 = 0x20 | 8;//9; // Assigning Highest Priority Slot to I2C0 and enabling this slot

VICVectAddr0 = (unsigned long)PWMISR; //Associate the address of timer0 with IRQ0 VICVectCntl0 = 0x20 | 8; //Enable slot 0 and associate it with Timer 0 VICIntEnable = 0x00100; //Enable PWM0 Interrupt

VICIntEnable = (1<<8);

}

//End of Timer initialization**************

/*****************************************/
/*****************************************/
//Start of Delay***************************
void delay (void) //Delay function
{ long i = 0;

for(i=0;i<1000000;i++); //For loop, does nothing for 100000 cycles

} //End of Delay*****************************

//__irq void PWMISR (void)
void __irq PWMISR(void)
{ PWMTCR = 0x00000002;//Reset counter and prescaler

PWMTCR = 0x9; // Enable (sart) PWM Note Match registers must be set prior to enable. Turn on Timer counter and Prescaler

test++; PWMIR = 0x08; VICVectAddr = 0; //Acknoledge the interrupt PWMIR = 0xFFFF; //Reset the interrupts
}

0