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.

DRV8312-C2-KIT: pwmdac_macro question

Part Number: DRV8312-C2-KIT

Hello:

 

I am trying to learn how to control sensor BLDC motor with DRV8312.  In ..\controlSUITE\development_kits\DRV8312-C2-KIT_v128\BLDC_Sensored firmware, I don’t understand the macro in line 164: “#define PWMDAC_MACRO(v)” at f2803xpwmdac_BLDC.h file.

 

I set “#define BUILDLEVEL LEVEL2” in BLDC_Sensored-Settings.h file.

 

When “PWMDAC_MACR0(pwmdac1)” is called in BLDC_Sensored.c file, it invokes the macro. Why in macro, TmpD and EPwm6Regs.CMPA.half.CMPA calculated like that?

 

Thanks, Jian

  • Refer to the comments.
    Convert 16-bit (Q0 or Q15) to 32-bit, execute "PWM Period(32-bit)" * "PWMDAC Duty Value(32-bit) to get the low 32-bit, and then get the high 16-bit of result (32-bit), to add PWM period/2.
    It means the PWMDAC input is Q15 from -1.0~1.0, is 0.5*Period+0.5*Period*DAC_Duty, to enable the output is 0.0~1.0*Period.