PWM CONFIGURATION IN LPC 804

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

PWM CONFIGURATION IN LPC 804

Jump to solution
669 Views
Arularasan
Contributor II

HI I am trying to generate pwm in P0_24  in LPC804 Microcontroler. 

If there are any changes in my configuration, update me 

int main()

{

 SYSCON->PRESETCTRL0 |= 1 << 25;

SYSCON->SYSAHBCLKCTRL0 |= 1<<7;

SWM0->PINASSIGN.PINASSIGN4 = 0X18;  // P0_24 PIN SELECTED

SYSCON->SYSAHBCLKCTRL0 |= 0<<7;

CTIMER->TCR |= 1 << 1;

CTIMER->PR = 0x00U;

CTIMER->MCR |= 1 << 0 | 1 << 1;

CTIMER->MR[0] =100;

CTIMER->MSR[0]=100;

CTIMER->PWMC |= 0<<1;

CTIMER->TCR |= 1<<0 | 1<<1;

while(1)
{
CTIMER->MR[1] =50;
CTIMER->MSR[1]=50; 
}

}

Tags (1)
0 Kudos
1 Solution
605 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Arularasan 

Please first confirm the PWM demo under SDK can generate PWM signal on your board, then development based on it, 

that can speeds up your development.

 

BR

Alice

View solution in original post

0 Kudos
3 Replies
653 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Arularasan 

What about the issue  with your project?

About PWM, strongly recommend you the PWM demo under SDK.

Download SDK from:  https://mcuxpresso.nxp.com/en/select  

 

BR

Alice

 

0 Kudos
645 Views
Arularasan
Contributor II

@Alice_Yang  

The pwm pulse is not generated, please update me if there are any changes in the configuration below

int main()

{

* 1 */ SYSCON->SYSAHBCLKCTRL0 |=  1 << 25 ;// Enables clock for CTIMER0.
 
/* 2 */ SYSCON->PRESETCTRL0 |= 1 << 25; //  CTIMER reset control // Clear the CTIMER reset.
 
/* 3 */ // Pins: Select timer pins through switch matrix.
 
/* 4 */    //  SWM0->PINASSIGN_DATA[4] | ;
 
    SYSCON->SYSAHBCLKCTRL0 |= 1<<7; //Enables clock for switch matrix
 
SWM0->PINASSIGN.PINASSIGN4 = 0X18;// P0_24 PIN SELECTED
 
SYSCON->SYSAHBCLKCTRL0 |= 0<<7; //DISABLE clock for switch matrix
 
/* 5 */  CTIMER->TCR |= 1 << 1;/*Enabled. The Timer Counter and the Prescale Counter are synchronously reset on the
                                 next positive edge of the APB bus clock. The counters remain reset until TCR[1] is
                                 returned to zero*/
CTIMER->PR = 0xFFFFFFFFU;
/* 6 */ CTIMER->MCR |= 1 << 0 | 1 << 1; // Interrupt on MR0: an interrupt is generated when MR0 matches the value in the TC
                                        // Reset on MR0: the TC will be reset if MR0 matches it. 0 = disabled. 1 = enabled
 
/* 7 */ CTIMER->MR[0] =100;//Timer counter match value
 
/* 8 */ CTIMER->MSR[0]=100; //Timer counter match shadow value
 
           //  START COUNT
 
/* 9 */ CTIMER->PWMC |= 0<<1;//PWM. PWM mode is enabled for CTIMER_MAT0.
 
/* 10 */ CTIMER->TCR |= 1<<0 | 1<<1;// Enabled. The Timer Counter and Prescale Counter are enabled.
                                    //Enabled. The Timer Counter and the Prescale Counter are synchronously reset on the
//next positive edge of the APB bus clock. The counters remain reset until TCR[1] is
//returned to zero
 // while(1)
 // {
  /* 7 */ CTIMER->MR[1] =50;//Timer counter match value
 
  /* 8 */ CTIMER->MSR[1]=50; //Timer counter match shadow value
 // }
}
0 Kudos
606 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello @Arularasan 

Please first confirm the PWM demo under SDK can generate PWM signal on your board, then development based on it, 

that can speeds up your development.

 

BR

Alice

0 Kudos