MPC5554 EQADC - Single Scan Software Mode . Not working . Please help!!

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

MPC5554 EQADC - Single Scan Software Mode . Not working . Please help!!

Jump to solution
4,465 Views
Vikram
Contributor II

I am developing EQADC driver software for the mpc5554 microcontroller. I am running the EQADC in single scan software mode and have written the program as per the Cook Book available in freescale site.

 

I am encountering 2 problems :

 

1. At the same voltage the microcontroller is giving different digital values in the RFIF0 register. I am using only RFIFO0 and CFIFO0 for the ADC scanning and reading result, as per the cook book source code.

2. At Zero Voltage as input I am getting values like 0x2edc etc even though the VRL = 0V.

Due to this problem my application has got stuck as the adc module is not working as expected. Please help!!!

 

It is very critical for my application.

0 Kudos
1 Solution
1,229 Views
Vikram
Contributor II

@Kylesh, The differential voltage issue also got solved. Actually, the differential analog voltage result in eQADC is as follows: Input+ Input- Result diff voltage 2.5 2.5 0x1FFC 0 1.25 3.75 0x0 -2.5 3.75 1.25 0x3FFC 2.5.

 

Ithought that the differential ADC is 0->+5V, but it is -2.5-> +2.5.

View solution in original post

0 Kudos
9 Replies
1,228 Views
kylesch
Contributor I

Ok, first the stupid question, but only because the symptoms fit...

 

I saw a similar effect when I didn't hook the source up to the right ADC pin. Also, another stupid suggestion, make sure that your CFPR register is loaded with the correct pin number, i.e. EQADC.CFPR[0].R = 0x80001900 for eQADC 25. 

 

On another note, were you able to get a successful conversion before you altered the cookbook program for your application? 

 

 

0 Kudos
1,228 Views
Vikram
Contributor II

Yes, I have checked that the signal is indeed connected to the right pin(Channel 2). I have not done any modiications in the cookbook code, but still the problem persists.

Below is the code which I am using :

 

#include "mpc5554.h" /* Use proper include file like mpc5510.h, mpc5554.h, mpc563m.h */

static uint32_t Result = 0; /* ADC conversion result */

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

void initADC0(void) {

EQADC.CFPR[0].R = 0x80801001; /* Send CFIFO 0 a ADC0 configuration command */

/* enable ADC0 & sets prescaler= divide by 2 */

EQADC.CFCR[0].R = 0x0410; /* Trigger CFIFO 0 using Single 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 = 0x80000200; /* Conversion command: convert channel 2 */

/* with ADC0, set EOQ, and send result to RFIFO 0 */

EQADC.CFCR[0].R = 0x0410; /* Trigger CFIFO 0 using Single 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) {

int i = 0; /* Dummy idle counter */

while (1) {

initADC0(); /* Enable ADC0 only on eQADC */

SendConvCmd(); /* Send one conversion command */

ReadResult(); /* Read result */

i++; /* Wait forever */

}

}

 

 

I am clueless about this problem.

0 Kudos
1,228 Views
kylesch
Contributor I

Ya, your code seems to be the same as mine.....

 

A couple other things you might try:

 

1. You didn't configure the SIU register for the ADC, that shouldn't make a difference but I have spent a day trying to figure out why a PWM didn't work because of the pad configuration.

 

2. Try sampling a different ADC channel, probably a stupid check but it might do something different which could give you a clue.

 

3. Try starting a new project and pasting your code in. I have had to do this a couple times when putting together new functions, usually you can trace it some configuration, the caching configuration or LCF file for me, but a replacement can sometimes go around the problem. 

 

0 Kudos
1,228 Views
Vikram
Contributor II
@kylesh, I think there is no SIU pad config register for ADC pins as such. I tried sampling other channels also, but I have the same problem. DO you have any sample ADC code with you which measures the input channels correctly. Please post here. Other than supplying VRH and VRL do we need to consider anything else at hardware level ?
0 Kudos
1,228 Views
kylesch
Contributor I

Right, I think that might be because the default for those pins is to be configured as an input. I have attached my test program here, as you can see it looks basically the same....

 

#include "MPC5554.h"

 

void initADC0(void) {

  EQADC.CFPR[0].R = 0x80801001;       /* Send CFIFO 0 a ADC0 configuration command */

  EQADC.CFCR[0].R = 0x0410;           /* Trigger CFIFO 0 using Single 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 = 0x80001900; /* Conversion command: convert channel 25 */

                                /* with ADC0, set EOQ, and send result to RFIFO 0 */ 

  EQADC.CFCR[0].R = 0x0410;     /* Trigger CFIFO 0 using Single Scan SW mode */

}

 

void ReadResult(void) {

uint32_t Result;

uint32_t ResultInMv;

  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) {

  int i = 0;   /* Dummy idle counter */

   initADC0();              /* Enable ADC0 only on eQADC */

  while (1) {

    SendConvCmd();          /* Send one conversion command */

    ReadResult();           /* Read result */

    i++;           /* Wait forever */

  }

}

 

0 Kudos
1,228 Views
zhenkun
Contributor I

I think when we set  EQADC.CFPR[0].R = 0x80801001; then the prescaler= divide by 34 not 2.

 can you explain this ?why it is prescaler= divide by 2?

0 Kudos
1,228 Views
Vikram
Contributor II

@kylesh,

               The problem is rectified now. I think the problem was with the development board I was using. I replaced the old one with a new one and now things are working fine.

 

I am now testing the differential adc of MPC5554. I am using channel AN0+ and AN0-. I am giving 5V to AN0+ and a variable potentiometer supply to AN0-. The ADC is giving steady values as I change the voltage level of AN0- and it seems to work fine.But, when I make both the AN0+ and AN0- pin as +5V, I think I should get 0x0 as the differential output, but I am getting 0x1FF1. But when I make AN0+ 5V and AN0- 0V, I get 3FFC(max value) as the differential output, which is correct.

 

Do you have any idea, why I am not getting 0x0 when both AN0+ anf AN0- are +5V.

The code is the same as above, only now the channel number is 96. 

 

0 Kudos
1,228 Views
kylesch
Contributor I

You gotta love when the problem is solved by replacing the HW. 

 

I am afraid that I won't be much help with the differiential conversions, we nixed them early in our design because of the range that they have; they can only read between +/- 2.5 V.  Have you tried different voltage levels?

0 Kudos
1,230 Views
Vikram
Contributor II

@Kylesh, The differential voltage issue also got solved. Actually, the differential analog voltage result in eQADC is as follows: Input+ Input- Result diff voltage 2.5 2.5 0x1FFC 0 1.25 3.75 0x0 -2.5 3.75 1.25 0x3FFC 2.5.

 

Ithought that the differential ADC is 0->+5V, but it is -2.5-> +2.5.

0 Kudos