AnsweredAssumed Answered

tPM PWM Fluctuation& Resolution (FRMD-K66F)

Question asked by JAEYONG SONG on Apr 5, 2019
Latest reply on Apr 12, 2019 by JAEYONG SONG



I am trying to send a PWM signal to a motor controller for torque control.

I have a couple of questions regarding tPM_PWM.


Firstly, the PWM signal is fluctuating within 0.5% around the target duty cycle when received at the motor controller.

My colleague has tried with Arduino to the motor controller and the duty cycle did not fluctuate. 

I modified an example code(tpm_simple_pwm) to make it run with FreeRTOS.

But it still has the same structure for PWM. 

The scheme is that when the SW button is pressed, it starts sending PWM to the motor controller. 

Here is the code I used.


if (Motor_Switch==1)
   /* Disable channel output before updating the dutycycle */
   TPM_UpdateChnlEdgeLevelSelect(TPM_BASEADDR, (tpm_chnl_t)TPM_CHANNEL, 0U);

   /* Update PWM duty cycle */
   TPM_UpdatePwmDutycycle(TPM_BASEADDR, (tpm_chnl_t)TPM_CHANNEL, kTPM_CenterAlignedPwm,

   /* Start channel output with updated dutycycle */
   TPM_UpdateChnlEdgeLevelSelect(TPM_BASEADDR, (tpm_chnl_t)TPM_CHANNEL, TPM_LED_ON_LEVEL);
/* Disable channel output before updating the dutycycle */
   TPM_UpdateChnlEdgeLevelSelect(TPM_BASEADDR, (tpm_chnl_t)TPM_CHANNEL, 0U);


PWM frequency of the motor controller is 5kHz and TPM_SetupPwm was set to 24kHz.

I tried to match those two values (TPM PWM was set to 5kHz).

(TPM_SetupPwm(TPM_BASEADDR, &tpmParam, 1U, kTPM_CenterAlignedPwm, 5000U, TPM_SOURCE_CLOCK);)




Secondly, according to the example code, I can only send duty cycle from 0% to 99% with 1% increment. 

I had a look at the underlying codes as well but I could not figure out how I can increase the resolution of the dutycycle.

Is there anywhere that I can change to increase the resolution of duty cycle?



Your advice will be very much appreciated.