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.

28335 EPWM 比较器更新,强制类型转换 问题

DSP28335 在更新EPWM 比较寄存器的时候,要把算完的小数 乘以 PWM周期,然后送给 CMPA 这里 是不是要强类型转换成整数? 是用int16  还是 Uint16啊???

下面是更新EPWM 比较寄存器,这样写对不对啊???????

int32 Tmp_a;    

      Tmp_a=p->PeriodMax*(p->MfuncC1);

       EPwm1Regs.CMPA.half.CMPA = (int16)Tmp_a;    

       EPwm1Regs.CMPB=(int16)Tmp_a;

其中 MfuncC1 存得是调制信号,正常时应该是0-1之间的数,不过也不排除有些时候可能会在0-1之外一点点。

或者在更新CMPA比较值的时候是否可以直接写:

EPwm1Regs.CMPA.half.CMPA =p->PeriodMax*(p->MfuncC1);

它是否会自己自动进行数据类型转换啊?

怎样写好呢????

谢谢!