LPC 55s16 PWM

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

LPC 55s16 PWM

1,122 Views
Arularasan
Contributor II

HI  I am Trying to generate PWM pulse in LPC 55s16 MCU 

"clock was not working"

as per User manual 

Select clock source. See Section 4.5.27 “CTimer 0 clock source select” to
Section 4.5.31 “CTimer 4 clock source select register”

Table 68. CTimer 2 clock source select (CTIMERCLKSEL2, offset = 0x274) bit description

" SYSCON->CTIMERCLKSELX[2] |= 0x00; " // CTimer 2 clock source select register .

but above register is not working.

So kindly update any correction in my configuration below

int main(void)
{
      
  SYSCON->CTIMERCLKSELX[2] |= 0x00; // CTimer 2 clock source select register


IOCON->PIO[1][6] = 0X003; // FUNC = 3 // CTIMER2_MAT1
SYSCON->AHBCLKCTRLX[1] = 1 << 22 ; // Enables the clock for the Timer 2.
SYSCON->PRESETCTRLSET[1] = 1 << 22 ; // Timer 2 reset control.
SYSCON->PRESETCTRLCLR[1] = 1 << 22 ; //clears the corresponding position in PRESETCTRL1.
CTIMER->CTCR = 0X00;//Timer mode. Incremented every rising APB bus clock edge
CTIMER->PR = 0X00;//The pre-scale counter is incremented on every APB bus clock
CTIMER->PWMC = 1 << 1 ;// PWM mode is enabled for CTIMERn_MAT1.
CTIMER->MCR = 1 << 10 ;// Reset on MR3: the TC will be reset if MR3 matches it.
CTIMER->MR[3] = 96000000 ;
CTIMER->MR[1] = 48000000 ;
CTIMER->TCR |= 1 << 0 ; //Enabled. The timer counter and pre-scale counter are enabled
while(1);
}

0 Kudos
Reply
7 Replies

1,077 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi Arularasan 

Can you please let us know your SDK version and demo project with configurations?

Thanks,

Jun Zhang

0 Kudos
Reply

1,055 Views
Arularasan
Contributor II

1 . SDK version : SDK_2.X_LPC_Xpresso5  2.13.0

2  .driver example : Ctimer_PWM_example  

3 .demo project with configurations are below ↓

"clock was not working"

as per User manual 

Select clock source. See Section 4.5.27 “CTimer 0 clock source select” to
Section 4.5.31 “CTimer 4 clock source select register”

Table 68. CTimer 2 clock source select (CTIMERCLKSEL2, offset = 0x274) bit description

" SYSCON->CTIMERCLKSELX[2] |= 0x00; " // CTimer 2 clock source select register .

but above register is not working.

So kindly update any correction in my configuration below

int main(void)
{
      
  SYSCON->CTIMERCLKSELX[2] |= 0x00; // CTimer 2 clock source select register


IOCON->PIO[1][6] = 0X003; // FUNC = 3 // CTIMER2_MAT1
SYSCON->AHBCLKCTRLX[1] = 1 << 22 ; // Enables the clock for the Timer 2.
SYSCON->PRESETCTRLSET[1] = 1 << 22 ; // Timer 2 reset control.
SYSCON->PRESETCTRLCLR[1] = 1 << 22 ; //clears the corresponding position in PRESETCTRL1.
CTIMER->CTCR = 0X00;//Timer mode. Incremented every rising APB bus clock edge
CTIMER->PR = 0X00;//The pre-scale counter is incremented on every APB bus clock
CTIMER->PWMC = 1 << 1 ;// PWM mode is enabled for CTIMERn_MAT1.
CTIMER->MCR = 1 << 10 ;// Reset on MR3: the TC will be reset if MR3 matches it.
CTIMER->MR[3] = 96000000 ;
CTIMER->MR[1] = 48000000 ;
CTIMER->TCR |= 1 << 0 ; //Enabled. The timer counter and pre-scale counter are enabled
while(1);
}

0 Kudos
Reply

1,039 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

Hi

So you want to change clock source as main clock

ZhangJennie_1-1690358068986.png

 

Thus configure the CTIMER2 clock source as main clock in clock configuration tool. try how it works.

ZhangJennie_0-1690358018291.png

Have a nice day.

Jun Zhang

 

0 Kudos
Reply

1,034 Views
Arularasan
Contributor II

CTIMER2 clock source as main clock is not working .

 

Arularasan_1-1690365057756.png

 

0 Kudos
Reply

1,030 Views
ZhangJennie
NXP TechSupport
NXP TechSupport

I am using ctimer_pwm_interrupt_example demo.

add CLOCK_AttachClk(kMAIN_CLK_to_CTIMER2); after BOARD_InitBootClocks();

BOARD_InitBootPins();
BOARD_InitBootClocks();
CLOCK_AttachClk(kMAIN_CLK_to_CTIMER2);
BOARD_InitDebugConsole();

ctimer works well.

Please test it.

0 Kudos
Reply

1,107 Views
Arularasan
Contributor II

@ErichStyger  Yes, the PWM example in the MCUXpresso SDK is Working.
But the driver configuration I write doesn't work...

what is the problem in these register  SYSCON->CTIMERCLKSELX[2] |= 0x00; // CTimer 2 clock source select register

Please edit and update ....

 

 

0 Kudos
Reply

1,115 Views
ErichStyger
Specialist I

Hi @Arularasan ,

have you checked the PWM example in the MCUXpresso SDK?

0 Kudos
Reply