This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

PWM Frequency issue

Hi all! must your help here.

I working of EFM32G222F128 and use with TIMER0 as PWM.

When I set freq of PWM (on code) = 1kHz -> I got 1kHz

When I set freq of PWM = 500Hz -> I got 500Hz

When I set freq of PWM = 50Hz -> I got ~790Hz (this frequency needed)

When I set freq of PWM = 3Hz -> I got 3kHz

What's going on here?!

The code for freq:

sl_pwm_config_t pwm_servo_config = {
.frequency = 50,
.polarity = PWM_ACTIVE_HIGH,
};

and for TIMER0:

void TIMER0_Init (void)
{
/* Enable clock for TIMER0 module */
CMU_ClockEnable(cmuClock_TIMER0, true);


/* Select TIMER0 parameters */
TIMER_Init_TypeDef timerInit =
{
.enable = true,
.debugRun = true,
.prescale = timerPrescale1024,
.clkSel = timerClkSelHFPerClk,
.fallAction = timerInputActionNone,
.riseAction = timerInputActionNone,
.mode = timerModeUp,
.dmaClrAct = false,
.quadModeX4 = false,
.oneShot = false,
.sync = false,
};

/* Enable overflow interrupt */
TIMER_IntEnable(TIMER0, TIMER_IF_OF);

/* Enable TIMER0 interrupt vector in NVIC */
NVIC_EnableIRQ(TIMER0_IRQn);

/* Set TIMER Top value */
TIMER_TopSet(TIMER0, 1000);

/* Configure TIMER */
TIMER_Init(TIMER0, &timerInit);


}

Thanks,

Gal.