Hi,
I am using MPC5748G Micro for ADC Conversion. I am using a circuit with 12Volts input. I need to monitor the input to that circuit using ADC, for that I am using Voltage Divider Circuit with 3.3Volts reference. I am continuously taking the readings through ADC channel but the readings are not constant, it is varying. I am using the below configurations for ADC. Please suggest if any corrections required.
void ADC1_PadConfig_ChanSelect(void) {
SIUL2.MSCR[PD0].B.APC = 1; /* PD0 = function ADC1_P[0] = ADC 1 channel 0 */
ADC_1.NCMR0.B.CH0 = 1; /* Enable channel 0 for normal conversion on ADC1 */
}
void ADC1_Calibration(void) {
uint32_t __attribute__ ((unused)) 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 */
}
}
void ADC1_Init(void) { /* Initialize ADC1 module & start normal scan mode */
ADC_1.MCR.B.PWDN = 1; /* Power down for starting module initialization */
ADC_1.MCR.B.OWREN = 0; /* Enable overwriting older conversion results */
ADC_1.MCR.B.MODE = 1; /* Scan mode (1) used instead of one shot mode */
ADC_1.MCR.B.ADCLKSEL = 1; /* ADC clock = FS80 bus clock (80 MHz here) */
ADC_1.MCR.B.PWDN = 0; /* ADC_1 ready to receive conversation triggers */
ADC_1.MCR.B.NSTART = 1; /* Initiate trigger for normal scan */
}
void ADC1_Read_Chan_0 (void) { /* Read conversion results */
Result= ADC_1.CDR[0].B.CDATA; /* Read channel 0 conversion result data */
ResultInMv = (uint16_t) (ADC_VREF*Result/0xFFF); /* Conversion in mV */
}
Thanks