Hello David,
The problem is probably caused by the big phase shift between voltage and current (the calibration value ramcfg.delayX is to big).
You can try change constant in the file “mk32z256_3ph.h”
#define ASD_L1M 0
#define ASD_L1M 4
#define ASD_L1M 8
But the best way should by to use the SW phase shift compensation method. You should by phased PDB, so to directly connect SD to SAR
/* AFE module */
SIM_SelAfePllClk (SIM_MCG_PLL_CLK);
AFE_ChInit (CH0,
AFE_CH_SWTRG_CCM_PGAOFF_CONFIG(DEC_OSR1024),
(0 * SAR_SCT),
PRI_LVL0,
(AFE_CH_CALLBACK)afech0_callback);
AFE_ChInit (CH1,
AFE_CH_SWTRG_CCM_PGAOFF_CONFIG(DEC_OSR1024),
(1 * SAR_SCT),
PRI_LVL0,
(AFE_CH_CALLBACK)afech1_callback);
AFE_ChInit (CH2,
AFE_CH_SWTRG_CCM_PGAOFF_CONFIG(DEC_OSR1024),
(2 * SAR_SCT),
PRI_LVL0,
(AFE_CH_CALLBACK)afech2_callback);
AFE_Init (AFE_MODULE_RJFORMAT_CONFIG(AFE_PLL_CLK, AFE_DIV2, AFE_CLK));
/* ADC module */
ADC_Init (ADC_MODULE_DIV4_16B_HWTRG_IREF_CONFIG,
HWAVG_OFF,
ADC_CH_SE_POLL_CONFIG(ADC_SE0),
ADC_CH_SE_POLL_CONFIG(ADC_SE1),
ADC_CH_SE_POLL_CONFIG(ADC_SE2),
ADC_CH_DISABLE_CONFIG,
PRI_LVL0,
(ADC_CALLBACK)NULL);
/* SD to SAR connection */
XBAR_Path (XBAR_AFE0COC, XBAR_ADCTRGCHA); // SAR start triger
XBAR_Path (XBAR_AFE1COC, XBAR_ADCTRGCHB); // SAR start triger
XBAR_Path (XBAR_AFE2COC, XBAR_ADCTRGCHC); // SAR start triger
And calculate phase shift by the library function
rotation = METERLIB3PH_ProcSamples(&mlib,u24_samplePh1,i24_samplePh1,u24_samplePh2,
i24_samplePh2,u24_samplePh3,i24_samplePh3,shift);
where the “shift” is defined
static frac16 shift[] = { METERLIB_DEG2SH(-5.5, 50.0),
METERLIB_DEG2SH(-5.5, 50.0),
METERLIB_DEG2SH(-5.5, 50.0) };
Where “-5.5” is angle for compensation and “50” is nominal line frequency….
Regards Lukas