PWM CONFIGURATION IN LPC 804

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PWM CONFIGURATION IN LPC 804

413 Views
Arularasan
Contributor II

PWM configuration not working!

I need to configure MR3 as period and MR0 as duty cycle

(50 % on time 50 % off time continuous pulse)

Is there any correction in my configuration below

int main(void)
{
SYSCON->SYSAHBCLKCTRL0 |=  1 << 25 ;  // Enables clock for CTIMER0.
 SYSCON->PRESETCTRL0 |= 1 << 25;                   //  CTIMER reset control // Clear the CTIMER reset.
 SYSCON->SYSAHBCLKCTRL0 |= 1<<7;                      //Enables clock for switch matrix
 SWM0->PINASSIGN.PINASSIGN4 = (0X18) << 24 ;   //0X18;// P0_24 PIN SELECTED
 SYSCON->SYSAHBCLKCTRL0 &= ~(1<<7); //DISABLE clock for switch matrix.
CTIMER->TCR |= 1 << 1;              //The Timer Counter and the Presale Counter are synchronously                                                              reset on the next positive edge of the APB bus clock
 CTIMER->PR = 0X00;  //Presale counter value
CTIMER->MCR |= 1 << 9 | 1 << 10 | 1 << 27 | 1 << 0 | 1 << 1;
CTIMER->MR[3] =10000;//Timer counter match value
 CTIMER->MSR[3]=10000; //Timer counter match shadow value
CTIMER->MR[0] =5000;//Timer counter match value
 CTIMER->MSR[0]=5000; //Timer counter match shadow value
CTIMER->PWMC |= 1<<3;//PWM. PWM mode is enabled for CTIMER_MAT0.
CTIMER->TCR |= 1<<0 ;//Enabled. The Timer Counter and Presale Counter are enabled
  while(1);
}
0 Kudos
Reply
1 Reply

387 Views
RaRo
NXP TechSupport
NXP TechSupport

Hello @Arularasan,

Could you please try out using the following arrangement to your code?

.
CTIMER->PR = 0X00; 
CTIMER->PWMC |= 1<<3;
CTIMER->MCR |= 1 << 9 | 1 << 10 | 1 << 27 | 1 << 0 | 1 << 1;
CTIMER->MR[0] =5000;
CTIMER->MR[3] =10000;
CTIMER->TCR |= 1<<0 ;
.

Also, there is a similar question on this post: LPC804 - PWM pulse generation - NXP Community, could you please take a look at it?

Best regards, Raul.

0 Kudos
Reply