Hi,
First of all, pls download data sheet of lpc5516 and check it in pin description. For example, the PIO0-0 can function as CTIMER0_MAT0, which means that the pin can function to output PWM signal.
PIO0_3 CTIMER0_MAT1
PIO0_5 CTIMER3_MAT0
PIO0_10 CTIMER2_MAT0
.....
In conclusion, all the CTIMERx_MATy pin can function as CTIMER PWM signal. In general, the MATCH0 register is used to configure the PWM period, so the CATIMERx_MAT0 is not used to output PWM. Of course, if you use the other match reg to control period, the MAT0 can be used to output PWM.
xiangjun_rong_0-1699839496009.png
2)The SDK has example to have the CTIMER output PWM signal
xiangjun_rong_1-1699840108212.png
In the ctimer_PWM example, the PWM signal can output from PIO1_4 pin which multiplexed with CTIMER2_MAT1.
The example uses CTIMER2 MAT2, we use the follow Macro
#define CTIMER CTIMER2 /* Timer 2 */
#define CTIMER_MAT_OUT kCTIMER_Match_1 /* Match output 1 */
In the pin_mux.c file, the following is defined:
const uint32_t port1_pin4_config = (/* Pin is configured as CTIMER2_MAT1 */
IOCON_PIO_FUNC3 |
/* No addition pin function */
IOCON_PIO_MODE_INACT |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT1 PIN4 (coords: 1) is configured as CTIMER2_MAT1 */
IOCON_PinMuxSet(IOCON, 1U, 4U, port1_pin4_config);
3)If you want to set the CTIMER2_MAT2 (pin PIO0_11) to output PWM. Pls try to use the code:
#define IOCON_PIO_FUNC2
const uint32_t port0_pin11_config = (/* Pin is configured as CTIMER2_MAT2 */
IOCON_PIO_FUNC2 |
/* No addition pin function */
IOCON_PIO_MODE_INACT |
/* Standard mode, output slew rate control is enabled */
IOCON_PIO_SLEW_STANDARD |
/* Input function is not inverted */
IOCON_PIO_INV_DI |
/* Enables digital function */
IOCON_PIO_DIGITAL_EN |
/* Open drain is disabled */
IOCON_PIO_OPENDRAIN_DI);
/* PORT0 PIN11 (coords: 1) is configured as CTIMER2_MAT2 */
IOCON_PinMuxSet(IOCON, 0U, 11U, port0_pin11_config);
In the main.c
#define CTIMER_MAT_OUT2 2
/* CTimer0 counter uses the AHB clock, some CTimer1 modules use the Aysnc clock */
srcClock_Hz = CTIMER_CLK_FREQ;
PRINTF("CTimer example to generate a PWM signal\r\n");
CTIMER_GetDefaultConfig(&config);
timerClock = srcClock_Hz / (config.prescale + 1);
CTIMER_Init(CTIMER, &config);
/* Get the PWM period match value and pulse width match value of 20Khz PWM signal with 20% dutycycle */
CTIMER_GetPwmPeriodValue(20000, 20, timerClock);
CTIMER_SetupPwmPeriod(CTIMER, CTIMER_MAT_PWM_PERIOD_CHANNEL, CTIMER_MAT_OUT, g_pwmPeriod, g_pulsePeriod, false);
CTIMER_SetupPwmPeriod(CTIMER, CTIMER_MAT_PWM_PERIOD_CHANNEL, CTIMER_MAT_OUT2, g_pwmPeriod, g_pulsePeriod, false);
CTIMER_StartTimer(CTIMER);
Pls have a try.
Hope it is helpful
BR
XiangJun Rong