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);
}
Hi Arularasan
Can you please let us know your SDK version and demo project with configurations?
Thanks,
Jun Zhang
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);
}
Hi
So you want to change clock source as main clock
Thus configure the CTIMER2 clock source as main clock in clock configuration tool. try how it works.
Have a nice day.
Jun Zhang
CTIMER2 clock source as main clock is not working .
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.
@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 ....
Hi @Arularasan ,
have you checked the PWM example in the MCUXpresso SDK?