Same result for ASM or CBE ±optimizer.
Code: Select all
#small1 = 1e-16
Macro ML_Tburst_from_PW_DC(PW_s_d, ducy_pc_d)
; PW_s_d = PulseWidth(s), ducy_pc_d = DutyCycle(%)
; Returns Tburst(s) = Burst period for a given Pulse Width and Duty Cycle
; Must force Floating point math with leading 0.0+ or /100.0
;FYI; inline error if outer parentheses removed!
(1 / ((1 / Abs(PW_s_d) * (Abs(ducy_pc_d) / 100.0)) + #small1))
EndMacro
Macro ML_Toff_from_PW_DC(PW_s_d, dc_pc_d)
; PW_s_d = PulseWidth(s), DC_pc_d = DutyCycle(%)
; RETURN: Toff(s) = burst period offtime for a given Pulse Width and Duty Cycle
ML_Tburst_from_PW_DC(PW_s_d, dc_pc_d) - Abs(PW_s_d)
EndMacro
Debug ML_Tburst_from_PW_DC(20e-6, 2)
Debug 1 / ML_Tburst_from_PW_DC(20e-6, 2)
Debug ML_Toff_from_PW_DC(20e-6, 2)
Debug StrD(ML_Toff_from_PW_DC(20e-6, 2) * 1e6) + " <-- WRONG"
Debug "Should be --> " + StrD(0.00097999999 * 1e6)
X.d = ML_Toff_from_PW_DC(20e-6, 2) * 1e6
Debug StrD(X) + " <-- Should be " + StrD(0.00097999999 * 1e6)
X.d = ML_Toff_from_PW_DC(20e-6, 2)
Debug StrD(X * 1e6) + " <-- OK if broken apart"