AnsweredAssumed Answered

Help Eqadc in MPC5634

Question asked by Jorge Ramon on Nov 21, 2016
Latest reply on Nov 22, 2016 by David Tosenovjan

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

Outcomes