Question about MPC5744P ADC Calibration?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Question about MPC5744P ADC Calibration?

519件の閲覧回数
liwuquan
Contributor III
NXP Expert,
The below code is from NXP DEVKIT- MPC5744P example S32DS project ADC_MPC5744P.
My question is inside the main() Can I switch the two function calls below:
 ADC1_PadConfig_ChanSelect();  /* Configure ADC pads & select scan channels */
 ADC1_Calibration();     /* Calibrate to compensate for variations */
to make it:
 ADC1_Calibration();     /* Calibrate to compensate for variations */
ADC1_PadConfig_ChanSelect();  /* Configure ADC pads & select scan channels */
?
\..\MPC574xP Quick Start Package Rev6\Code Project Examples for MPC574xP\ADC_MPC5744P
int main(void)
{
 int counter = 0;
 
 xcptn_xmpl ();              /* Configure and Enable Interrupts */
 peri_clock_gating();    /* Configure gating/enabling peri. clocks for modes*/
 system160mhz();         /* sysclk=160MHz, dividers configured, mode trans*/
 LED_Config();           /* Assign LED ports on Freescale LED as GPIO outputs*/
 MC_CGM.AC0_SC.B.SELCTL = 0b10; //Select PLL0_PHI as source of ADC analog clock
 MC_CGM.AC0_DC2.R = 0x80040000; //Enable ADC_CLK and divide PLL0_PHI source by 5 (i.e. 4+1)
 ADC1_PadConfig_ChanSelect();  /* Configure ADC pads & select scan channels */
 ADC1_Calibration();     /* Calibrate to compensate for variations */
 ADC1_Init();            /* Initialize ADC1 module & start normal scan mode */
 for(;;) {   
     counter++;
  if (ADC_1.ISR.B.ECH) { /* If normal scan channels finished converting */
    ADC1_Read_Chan();    /* Read conversion results */
    update_LEDs();       /* Update LEDs with scaled chan 1 result */
    ADC_1.ISR.R = 0x00000001; /* Clear End of CHain (ECH) status bit */
  }
 }
 return 0;
}
void ADC1_PadConfig_ChanSelect(void) { /* Config ADC pads & select scan chans */
     /* Note:  MSCR.SSS configuration  is not needed for inputs if there is  */
     /*        no SSS value is in signal spreadsheet */
     /* Note:  ADC1 Channel 6 on PE12 is connected to XDEVKIT-MPC5744P potentiometer. */
 SIUL2.MSCR[PE12].B.APC = 1; //Configure ADC1_AN6 to analog pad control function. Analog is default function so SSS says 0
 ADC_1.NCMR0.B.CH6 = 1; //Enable channel 6 for normal conversion on ADC1
}
void ADC1_Calibration(void) {       /* Steps below are from reference manual */
  uint32_t ADC1_Calibration_Failed = 1;    /* Calibration has not passed yet */
  ADC_1.MCR.B.PWDN = 1;     /* Power down for starting calibration process */
  ADC_1.MCR.B.ADCLKSEL = 0; /* ADC clock = bus clock/2 (80/2 MHz FS80) */
        /* Note: Calibration requires it to be set at max 40MHz for best results */
  ADC_1.CALBISTREG.B.TEST_EN = 1;       /* Enable calibration test */
  ADC_1.MCR.B.PWDN = 0;     /* Power back up for calibration test to start */
  while(ADC_1.CALBISTREG.B.C_T_BUSY);  /* Wait for calibration to finish */
  if(ADC_1.MSR.B.CALIBRTD) {            /* If calibration ran successfully */
    ADC1_Calibration_Failed = 0;        /* Calibration was successful */
  }
  else  {
    ADC1_Calibration_Failed = 1;        /* Calibration was not successful */
  }
  if(ADC1_Calibration_Failed){} //Functionally useless statement to make compiler happy
}
Another information in your AN4881:
6. SAR ADC initialization example
To initialize the SAR ADC, the following steps must be completed as a minimum:
1. Configure input pads and ADC normal conversion registers
2. Calibrate the ADC
3. Initialize SAR ADC modes and clock
4. Power on the ADC and start conversions
My similar question is Can switch order of 1. and 2. above?
Thank you.
Susan Li
1 返信

377件の閲覧回数
davidtosenovjan
NXP TechSupport
NXP TechSupport

Hi, probably yes, because calibration uses internal channels thus there in no need to have configured input pads.