Help Eqadc in MPC5634

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help Eqadc in MPC5634

1,012 Views
jorgeramon
Contributor II

I need to read 2 analog signals from the internal combustion engine by means of the eqadc this signal I can read only in simple mode or in continuous mode. How you should configure the channels. I have the following code

 

void initSysclk (void);
void initADC0(void);
void SendConvCmd (void);
void ReadResult(void);


void initSysclk (void) {

FMPLL.ESYNCR2.R = 0x00000002;
FMPLL.ESYNCR1.R = 0xF0000028;
while (FMPLL.SYNSR.B.LOCK != 1) {}; /* Wait for FMPLL to LOCK */
FMPLL.ESYNCR2.R = 0x00000001; /* Fsys =80Mhz */
}

static uint32_t Result = 0; /* ADC conversion result */
static uint32_t ResultInMv = 0; /* ADC conversion result in millivolts */

 

void initADC0(void) {
EQADC.MCR.R = 0x00000000;

EQADC.CFPR[0].R = 0x80800F01; /* Send CFIFO 0 a ADC0 configuration command */
/* enable ADC0 & sets prescaler= divide by 32 */
EQADC.CFCR[0].R = 0x0090; /* Trigger CFIFO 0 using Continues Scan SW mode */
while (EQADC.FISR[0].B.EOQF !=1) {} /* Wait for End Of Queue flag */
EQADC.FISR[0].B.EOQF = 1; /* Clear End Of Queue flag */
}

 

void SendConvCmd (void) {

 

EQADC.CFPR[0].R = 0x80001100; /* Conversion command: convert channel 7 */
/* with ADC0, set EOQ, and send result to RFIFO 0 */
EQADC.CFCR[0].R = 0x0090; /* Trigger CFIFO 0 using Continues Scan SW mode */

}


void ReadResult(void) {
while (EQADC.FISR[0].B.RFDF != 1){} /* Wait for RFIFO 0's Drain Flag to set */
Result = EQADC.RFPR[0].R; /* ADC result */
ResultInMv = (uint32_t)((5000*Result)/0x3FFC); /* ADC result in millivolts */
EQADC.FISR[0].B.RFDF = 1; /* Clear RFIFO 0's Drain Flag */
EQADC.FISR[0].B.EOQF = 1; /* Clear CFIFO's End of Queue flag */
}

int main(void) {

initSysclk ();
initADC0();

while (1) {

SendConvCmd(); /* Send one conversion command */
ReadResult(); /* Read result */

}

}

 

 

THANKS

Labels (1)
Tags (2)
0 Kudos
1 Reply

647 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Hi, I think this code is based on AN2865.

I believe can offer you better example codes. Pay attention to:

Example MPC5644A eQADC channel 146 conversion+calibration CW210 

Example MPC5674F eQADC+eDMA Single_Scan CW210 

Example MPC5674F eQADC+eDMA Continuous_Scan CW210 

Hope it helps.