read single a/d channel on MPC5567

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

read single a/d channel on MPC5567

567 Views
veneff
Contributor I

Hi,

I must be missing something obvious.

We have a device that we have been using for quite a while and I'm trying to add the capability to read one of 16 a/d channels.

This is a multi-layered board with a 416 pin MPC5567; so, can't verify that the voltage signal is Actually getting to the processor.  But it was laid out with that in mind and I have verified that the signal I am trying to measure does exist at some point on the printed circuit board.

Here is my, very simple, code, mostly from the simple cookbook example:

EQADC.CFPR[0].R = 0x80800B01;           /* Send CFIFO 0 a ADC0 configuration command */
                                            /* enable ADC0 & sets prescaler= divide by 24*/
                                            /* assuming system clock = 132 Mhz*/
                                            /*  and target A/D clock to be < 6 Mhz */
EQADC.CFCR[0].R = 0x0410;               /* Trigger CFIFO 0 using Single Scan SW mode */
while (EQADC.FISR[0].B.EOQF != 1);
EQADC.FISR[0].B.EOQF = 1;               /* Clear End Of Queue flag */

EQADC.CFPR[0].R = 0x80000000 + ((channel_number & 0x0F)<<8);
                                            /* Conversion command: convert channel n */
                                            /* with ADC0, set EOQ, and send result to RFIFO 0*/
EQADC.CFCR[0].R = 0x0410;               /* Trigger CFIFO 0 using Single Scan SW mode */
// wait for and read result
while (EQADC.FISR[0].B.RFDF != 1);      /* Wait for RFIFO 0's Drain Flag to set*/
result = EQADC.RFPR[0].R;               /* ADC result */

//  result = (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 */

please excuse the formatting, I haven't figure how to use the controls on this forum submission.

The symptoms are the result changes randomly when the voltage remains constant and the result does not have any relation to the voltage when I double it.

Vance

What have I overlooked?

0 Kudos
3 Replies

410 Views
davidtosenovjan
NXP TechSupport
NXP TechSupport

Could you specify how you obtained incorrect result? Are you executing described sequence in cycle or other way? What is actual channel number and what is measured signal? Check erratum e1773.

0 Kudos

410 Views
veneff
Contributor I

David,

Thanks for your response!

The voltage to be measured is applied to a voltage divider 100k - 10k connected to the analog input.  There is a separate (similar) voltage divider for each input AN0 to AN15.  The channel_number is set to 14 (0x0E).  The initialization portion of the included code (up through the first Clear End Of Queue flag) is done after the device powers up.  The rest of the code is called on command and the value result is printed as a decimal #.

I am applying either 12 or 24 volts at that input, so the AN14 should measure either 1.091 or 2.182, which it does (at least at the divider output).

Each time I call the conversion routine it comes back with what looks to be  floating input measurements:

236, 148, 132, 216, 124, 176, 144, 140, etc. without regard if 12 or 24 volts are applied.  Note: I also printed the channel # to be sure it was 14.

VDDA0 & VDDA1 are connected to 5volts.  VDDEH9 is connected to 3.3volts.  So there could be an issue here at higher voltages; but should not be an issue in this case.

Vance

0 Kudos

410 Views
veneff
Contributor I

So, as far as anyone can tell, the code shown above should work?

Vance

0 Kudos