PWM CONFIGURATION IN LPC 804

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

PWM CONFIGURATION IN LPC 804

跳至解决方案
863 次查看
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; 
}

}

标记 (1)
0 项奖励
回复
1 解答
799 次查看
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 项奖励
回复
3 回复数
847 次查看
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 项奖励
回复
839 次查看
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 项奖励
回复
800 次查看
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 项奖励
回复