we use ePWM to profiling our CLA code。
the CLA code list as follow:
EPwm3Regs.AQCSFRC.bit.CSFA=2;
CNTL_2P2Z_CLA_C(coeffs, vars);
EPwm3Regs.AQCSFRC.bit.CSFA=1;
we can see epwm3 waves from the scope and get how many time does this function make。
the function CNTL_2P2Z_CLA_C is defined as follow:
#define CNTL_2P2Z_CLA_C(v, k) \
/* Calculate error */ \
k.Errn = k.Ref - k.Fdbk; \
k.OutPresat = (v.Coeff_A2 * k.Out2) + (v.Coeff_A1 * k.Out1) + (v.Coeff_B2 * k.Errn2) \
+ (v.Coeff_B1 * k.Errn1) + (v.Coeff_B0 * k.Errn); \
\
/* Update error values */ \
k.Errn2 = k.Errn1; \
k.Errn1 = k.Errn; \
\
/* Determine new output */ \
k.Out = k.OutPresat; \
k.Out = (k.Out < v.Max) ? k.Out : v.Max; \
k.Out = (k.Out > v.IMin) ? k.Out : v.IMin; \
\
/* Store outputs */ \
k.Out2 = k.Out1; \
k.Out1 = k.Out; \
/* Saturated output */ \
k.Out = ((k.Out > v.Min) ? k.Out : v.Min)
use the function defined,we get test time:470ms
but just remove the last code of the function,the function is as follow:
#define CNTL_2P2Z_CLA_C(v, k) \
/* Calculate error */ \
k.Errn = k.Ref - k.Fdbk; \
k.OutPresat = (v.Coeff_A2 * k.Out2) + (v.Coeff_A1 * k.Out1) + (v.Coeff_B2 * k.Errn2) \
+ (v.Coeff_B1 * k.Errn1) + (v.Coeff_B0 * k.Errn); \
\
/* Update error values */ \
k.Errn2 = k.Errn1; \
k.Errn1 = k.Errn; \
\
/* Determine new output */ \
k.Out = k.OutPresat; \
k.Out = (k.Out < v.Max) ? k.Out : v.Max; \
k.Out = (k.Out > v.IMin) ? k.Out : v.IMin; \
\
/* Store outputs */ \
k.Out2 = k.Out1; \
k.Out1 = k.Out; \
/* Saturated output */ \
/*k.Out = ((k.Out > v.Min) ? k.Out : v.Min)*/
we get 10us when we use (the remove last code) function。
Q:why just remove last code we get diff result。