This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TMS320F28069F: Motorware software : the function of HAL_writePwmData()

Part Number: TMS320F28069F


Hello,

I have a question on the Motorware software for TMS320F2806xF devices.

Specifically it is on the function of HAL_writePwmData() listed in the file of hal.h.

I cannot understand the following assignment code:

period = (_iq)pwm->TBPRD;

The local variable of period is declared as _iq.

Meanwhile the value of pwm->TBPRD might be 90*250/2=11,250 for the PWM frequency of 4 kHz as assigned in the function of HAL_setupPwms() listed in the file of hal.c.

Obviously the value of 11,250 is beyond the range of _iq or Q24 number.

Please inform me where I am wrong.

Thank you for your guidance.

With regards,

JS Yoo

  • It just uses _iq to force convert the uint16_t (unsigned int) type variable to a long type, the final result is equal to _IQ0(pwm->TBPRD), not _IQ(pwm->TBPRD). _iq doesn't like using _IQ() to converts a floating-point constant or variable to the equivalent IQ value. 

  • Hi Yanming Luo,

    Thank you for your review.

    I have more questions on the function of HAL_writePwmData() as follows.

    Specifically it is on the assignment code shown below.

    value = _IQmpy(pwmData_sat_dc, period);

    The function of _IQmpy(A,B) is defined as __IQmpy(A,B,GLOBAL_Q).

    Futhermore GLOBAL_Q is defined as 24.

    Therefore I suppose that the function  _IQmpy(pwmData_sat_dc, period) returns a number in the range of Q24 format.

    It seems that the variable of pwmData_sat_dc has a value between _IQ(0.0) and _IQ(1.0).

    Then I suppose that the output of  _IQmpy(pwmData_sat_dc, period) may exceed the range of Q24 format because the variable of period exceeds the range of Q24 format.

    Am I wrong?

    Please inform me where I am wrong.

    Thank you for your guidance.

    With regards,

    JS Yoo

  • No overflow at here. The "period" will be used as _IQ in this equation that equals to _IQmpy(pwmData_sat_dc, _IQ( the value of "period"/2^24)), not _IQmpy(pwmData_sat_dc, _IQ(the value of "period")).