I am looking at the sctimer_simple_pwm example provided for lpc54018.
According to the pin table for UM11079. for J11 area, the Sctimer output and pin correspondence are
Index Pin SCTimer_OUT
1 2_2 6
2 3_28 2
3 3_14 4
4 3_10 3
....
The provided example is
#define DEMO_FIRST_SCTIMER_OUT kSCTIMER_Out_4
#define DEMO_SECOND_SCTIMER_OUT kSCTIMER_Out_2
int main(void)
{
sctimer_config_t sctimerInfo;
sctimer_pwm_signal_param_t pwmParam;
uint32_t event;
uint32_t sctimerClock;
/* Board pin, clock, debug console init */
/* attach 12 MHz clock to FLEXCOMM0 (debug console) */
CLOCK_AttachClk(BOARD_DEBUG_UART_CLK_ATTACH);
BOARD_InitPins();
BOARD_BootClockFROHF96M();
BOARD_InitDebugConsole();
sctimerClock = SCTIMER_CLK_FREQ;
SCTIMER_GetDefaultConfig(&sctimerInfo);
/* Initialize SCTimer module */
SCTIMER_Init(SCT0, &sctimerInfo);
/* Configure first PWM with frequency 24kHZ from first output */
pwmParam.output = DEMO_FIRST_SCTIMER_OUT;
pwmParam.level = kSCTIMER_HighTrue;
pwmParam.dutyCyclePercent = 50;
if (SCTIMER_SetupPwm(SCT0, &pwmParam, kSCTIMER_CenterAlignedPwm, 24000U, sctimerClock, &event) == kStatus_Fail)
{
return -1;
}
/* Configure second PWM with different duty cycle but same frequency as before */
pwmParam.output = DEMO_SECOND_SCTIMER_OUT;
pwmParam.level = kSCTIMER_LowTrue;
pwmParam.dutyCyclePercent = 20;
if (SCTIMER_SetupPwm(SCT0, &pwmParam, kSCTIMER_CenterAlignedPwm, 24000U, sctimerClock, &event) == kStatus_Fail)
{
return -1;
}
/* Start the timer */
SCTIMER_StartTimer(SCT0, kSCTIMER_Counter_L);
while (1)
{
}
}
And it worked.
However, if I change kSCTIMER_Out_4 into kSCTIMER_Out_6 or kSCTIMER_Out_3, and plug the LED into the corresponding pinholes, the LED is not flickering.
Why only kSCTIMER_Out_4 and kSCTIMER_Out_2 works? How may I use the rest of the pinholes? (I need a third pinhole to PWM a tricolor LED)
Thanks,
Jenny
Solved! Go to Solution.
Hi Jenny,
Yes, if you want to change the STC output pin, you also need to modify the pin_mux BOARD_InitPins function.
You need to define P2_2 and P3_10 FUNC to SCT output function.
So, now, when you define the according pin configuration, do you make it works?
const uint32_t port2_pin2_config = (
IOCON_PIO_FUNC3 | /* Pin is configured as SCT0_OUT4 */
IOCON_PIO_MODE_INACT | /* No addition pin function */
IOCON_PIO_INV_DI | /* Input function is not inverted */
IOCON_PIO_DIGITAL_EN | /* Enables digital function */
IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
);
IOCON_PinMuxSet(IOCON, 2u, 2u, port2_pin2_config );
const uint32_t port3_pin10_config = (
IOCON_PIO_FUNC1 | /* Pin is configured as SCT0_OUT2 */
IOCON_PIO_MODE_INACT | /* No addition pin function */
IOCON_PIO_INV_DI | /* Input function is not inverted */
IOCON_PIO_DIGITAL_EN | /* Enables digital function */
IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
);
IOCON_PinMuxSet(IOCON, PORT3_IDX, 10u, port3_pin10_config );
If you still have problem about it, please kindly let me know.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------
It turns out in the board/src/pin_mux
in BOARD_InitPins()
you need to define something like
port2_pin2_config if you wanna use the SCTimer_out_6 P2_2 correspond to
check line 120-140 for examples of P3_14 (SCTimer_out_4) and P3_28(SCTimer_out_2)
Hi Jenny,
Yes, if you want to change the STC output pin, you also need to modify the pin_mux BOARD_InitPins function.
You need to define P2_2 and P3_10 FUNC to SCT output function.
So, now, when you define the according pin configuration, do you make it works?
const uint32_t port2_pin2_config = (
IOCON_PIO_FUNC3 | /* Pin is configured as SCT0_OUT4 */
IOCON_PIO_MODE_INACT | /* No addition pin function */
IOCON_PIO_INV_DI | /* Input function is not inverted */
IOCON_PIO_DIGITAL_EN | /* Enables digital function */
IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
);
IOCON_PinMuxSet(IOCON, 2u, 2u, port2_pin2_config );
const uint32_t port3_pin10_config = (
IOCON_PIO_FUNC1 | /* Pin is configured as SCT0_OUT2 */
IOCON_PIO_MODE_INACT | /* No addition pin function */
IOCON_PIO_INV_DI | /* Input function is not inverted */
IOCON_PIO_DIGITAL_EN | /* Enables digital function */
IOCON_PIO_INPFILT_OFF | /* Input filter disabled */
IOCON_PIO_SLEW_STANDARD | /* Standard mode, output slew rate control is enabled */
IOCON_PIO_OPENDRAIN_DI /* Open drain is disabled */
);
IOCON_PinMuxSet(IOCON, PORT3_IDX, 10u, port3_pin10_config );
If you still have problem about it, please kindly let me know.
Have a great day,
Kerry
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------