Part Number: CC2650
I use the following code to set the PWM with the correct frequency and fill. However, it does not work if I set the frequency to less than 700 kHz.
How can I set the timer so that the PWM frequency is, for example, 300kHz? 100kHz?
void pwm_set(uint32_t freq, uint8_t duty_percent)
{
ti_lib_timer_disable(GPT0_BASE, TIMER_A);
ti_lib_ioc_port_configure_set(PWM_GPIO, IOC_PORT_MCU_PORT_EVENT0, IOC_STD_OUTPUT);
ti_lib_timer_configure(GPT0_BASE, TIMER_CFG_SPLIT_PAIR|TIMER_CFG_A_PWM);
uint32_t interval_load, interval_match;
uint32_t match_divider = 100*100 / duty_percent;
interval_load = GET_MCU_CLOCK / freq;
interval_match = ((interval_load * 100) / match_divider);
ti_lib_timer_load_set(GPT0_BASE, TIMER_A, interval_load);
ti_lib_timer_match_set(GPT0_BASE, TIMER_A, interval_match);
ti_lib_timer_enable(GPT0_BASE, TIMER_A);
}
