Hi Jun,
Now I'm trying to turn on at pin 60 (CTIMER0_MATCH0) as a PWM signal and then sync with GPIO output at pin 55 so I can use three PWM channels at the same time. Will the other two 53 pins (CTIMER0_MATCH1) and 58 pins (CTIMER0_MATCH2) affect the GPIO output of 55 pins? Here's my code for that
void ctimer0_init(void)
{
ctimer_config_t config;
uint32_t srcClock_Hz;
CLOCK_AttachClk(kFRO_HF_to_CTIMER0);
srcClock_Hz = CTIMER0_CLK_FREQ;
CTIMER_GetDefaultConfig(&config);
timerClock = srcClock_Hz / (config.prescale + 1);
CTIMER_Init(CTIMER0, &config);
CTIMER_RegisterCallBack(CTIMER0, &ctimer_callback[0], kCTIMER_SingleCallback); //kCTIMER_MultipleCallback kCTIMER_SingleCallback
/* Get the PWM period match value and pulse width match value of 2Khz PWM signal */
CTIMER_GetPwmPeriodValue(PWM_FRQ, dutyCycle, timerClock);
CTIMER_SetupPwmPeriod(CTIMER0, CTIMER0_MAT0_PWM_PERIOD_CHANNEL, CTIMER0_MAT0_OUT, g_pwmPeriod, g_pulsePeriod, true);
CTIMER_SetupPwmPeriod(CTIMER0, CTIMER0_MAT0_PWM_PERIOD_CHANNEL, CTIMER0_MAT1_OUT, g_pwmPeriod, g_pulsePeriod, true);
CTIMER_SetupPwmPeriod(CTIMER0, CTIMER0_MAT0_PWM_PERIOD_CHANNEL, CTIMER0_MAT2_OUT, g_pwmPeriod, g_pulsePeriod, true);
pwm_set_duty(global_bright_rgb);
CTIMER_StartTimer(CTIMER0);
}
if (CTIMER_GetOutputMatchStatus(CTIMER0, CTIMER0_MAT0_OUT))
{
bsp_led_off(LED_B);
}
else
{
bsp_led_on(LED_B);
}
void pwm_match_callback(uint32_t flags)
{
(void) flags;
if (times_ms >0)
{
times_ms--;
}
}
Thanks!