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 dutyCycleSet set to 100% doesn't work


I tried to create a function that would set a duty cycle of the PWM pin at runtime. The problem is that if I set the duty cycle to 100% the dutyCycleSet function returns an error.

status = g_fan.p_api->dutyCycleSet(g_fan.p_ctrl, 100, TIMER_PWM_UNIT_PERCENT, PIN);

Why? I have not figured out how to solve it.

Best regards


Parents Reply Children
  • Hi Ian.


    I made a workaround that should work.
    I still have to see with the oscilloscope if it's correct.

    if (99 < duty) {
            gpt_instance_ctrl_t * p_ctrl = (gpt_instance_ctrl_t *) g_fan.p_ctrl;
            R_GPTA0_Type *p_gpt_reg = (R_GPTA0_Type *) p_ctrl->p_reg;
            p_gpt_reg->GTUDDTYC_b.OADTY = 3;
        else {
            ssp_err_t status = g_fan.p_api->dutyCycleSet(g_fan.p_ctrl, duty, TIMER_PWM_UNIT_PERCENT, PIN);
            if (SSP_SUCCESS != status)
    #ifndef NDEBUG


  • I confirm that my workaround works Slight smile