I try to test ADC calibration function, but when calibration over, the ADC_CALBISTREG.TEST_FAIL is set.
I don't know why. The following is source code.
p_ADC->MCR.B.PWDN = 1;
while(p_ADC->MSR.B.ADCSTATUS != 1); /* wait for powerdown */
p_ADC->MCR.B.ADCLKSEL = 0; /* ADC clock frequency is half of bus clock */
p_ADC->CALBISTREG.R = CAL_HIGH_ACCURACY_MODE | CAL_22_CYCLES | CAL_512_SAMPLES | CAL_AVAG_EN | CAL_TEST_FAIL_CLEAR;
p_ADC->MCR.B.PWDN = 0; /* power up */
while(p_ADC->MSR.B.ADCSTATUS != 0); /* wait for power up */
p_ADC->CALBISTREG.B.TEST_EN = 1; /* enable calibration */
/* wait for calibration complete, MSR.ADCSTATUS or CALBISTREG.C_T_BUSY */
while(p_ADC->CALBISTREG.B.C_T_BUSY){
;
}
/* get calibration result */
cal_result = p_ADC->CALBISTREG.B.TEST_FAIL;
Hi, I haven’t tried it yet, but the sequence mentioned in section “36.5.10.1 Calibration (High Accuracy mode)” says little bit different sequence:
default values are set for maximum accuracy (recommended).
CALBISTREG[C_T_BUSY] becomes 0.
successful.
CALBISTREG[TEST_FAIL] = 1.
This sequence first do power-up of the ADC and in next step it configures CALBISTREG. It would be good to check it.
RM say that:
“The calibration routine sets the fail flag (CALBISTREG[TEST_FAIL]) to indicate:
Calibration is aborted if a normal conversion is initiated during calibration; this is called
premature termination. The terminating conversion and the immediate next one to it will
have invalid result in this case.”
Conversions without calibration works fine to you or not?