MCF52235 ADC issue - AN7 as ADC input, never get read value in software routine?

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

MCF52235 ADC issue - AN7 as ADC input, never get read value in software routine?

1,784 Views
TVNAIDU
Contributor III


I have question about ADC of 52233 chipset. I am using AN0 to AN5 as GPIO output for analog chip select and AN7 pin as ADC input. When I select chip using AN0-5, I can see sample on AN7 using scope, but when I read in software routine, I am not getting value.

I am reading AN7 using this:
 volt_buf1 = (int)  ((MCF_ADC_ADRSLT7&0x7FF8) >> 3);

but I never get AN7 valu into volt_buf1, any reason?

 

 

this is init code for AN0-5 and AN7

 

//AN0-5 as GPIO output and AN7 as ADC Input:

MCF_GPIO_DDRAN =
     MCF_GPIO_DDRAN_DDRAN6 |
     MCF_GPIO_DDRAN_DDRAN5 |
     MCF_GPIO_DDRAN_DDRAN4 |
     MCF_GPIO_DDRAN_DDRAN3 |
     MCF_GPIO_DDRAN_DDRAN2 |
     MCF_GPIO_DDRAN_DDRAN1 |
     MCF_GPIO_DDRAN_DDRAN0 ;


//AN7 as ADC input
MCF_GPIO_PANPAR = MCF_GPIO_PANPAR_PANPAR7;

MCF_GPIO_PORTAN = 0;

Thanks for help



Labels (1)
0 Kudos
7 Replies

614 Views
mjbcswitzerland
Specialist V

Hi

 

Have you configured the ADC itself for operation? Note also that there are 2 ADC circuits (A and B). AN0..3 require circuit A to be powered and AN4..7 require circuit B.

 

See also:

http://www.utasker.com/forum/index.php?topic=888.0

 

Regards

 

Mark

 

www.uTasker.com

 

0 Kudos

614 Views
TVNAIDU
Contributor III

 

I am not getting first ADC reading when I select first chip using AN0-AN4, I am getting its value when I select 2nd one only, samething for 2nd one also, it is getting offset by one, do I need delay. current;y I have printf, may be printf adding that delay.  Here I get volt1_buf correct value at curr1_buf, also curr1_buf correct val at curr2_buf and so on. Here I am using AN0-4 as GPIO inputs to select chipset and AN7 as ADC input.

 

 

VOLT1_READ;  (macro selects first chipset by AN0-2 are low, AN3 and 4 are high)

for(i=0;i<0x22;i++) {}

volt1_buf = (int) ((MCF_ADC_ADRSLT7 & 0x7FF8) >> 3);

printf("VOLT1 ADC val: %d\n", volt1_buf);

 

CURR1_READ;

for(i=0;i<0x22;i++) {}

curr1_buf = (int) ((MCF_ADC_ADRSLT7 & 0x7FF8) >> 3);

printf("CURR1 ADC val: %d\n", curr1_buf);

 

CURR2_READ;

for(i=0;i<0x22;i++) {}

curr2_buf = (int) ((MCF_ADC_ADRSLT7 & 0x7FF8) >> 3);

printf("CURR2 ADC val: %d\n", curr2_buf);

......

.....

CURR8_READ;

for(i=0;i<0x22;i++) {}

curr8_buf = (int) ((MCF_ADC_ADRSLT7 & 0x7FF8) >> 3);

printf("CURR8 ADC val: %d\n", curr8_buf);

 

 

VOLT2_READ;  (macro selects first chipset by AN0-2 are low, AN3 and 4 are high)

for(i=0;i<0x22;i++) {}

volt2_buf = (int) ((MCF_ADC_ADRSLT7 & 0x7FF8) >> 3);

printf("VOLT2 ADC val: %d\n", volt2_buf);

 

CURR9_READ;

for(i=0;i<0x22;i++) {}

curr9_buf = (int) ((MCF_ADC_ADRSLT7 & 0x7FF8) >> 3);

printf("CURR9 ADC val: %d\n", curr9_buf);

 

CURR10_READ;

for(i=0;i<0x22;i++) {}

curr10_buf = (int) ((MCF_ADC_ADRSLT7 & 0x7FF8) >> 3);

printf("CURR10 ADC val: %d\n", curr10_buf);

......

.....

CURR16_READ;

for(i=0;i<0x22;i++) {}

curr16_buf = (int) ((MCF_ADC_ADRSLT7 & 0x7FF8) >> 3);

printf("CURR16 ADC val: %d\n", curr16_buf);

 

 

 

0 Kudos

614 Views
TVNAIDU
Contributor III

The above printf's for VOLT_BUF and CURR_BUF only helps to get first value at second place, second value at third place, if I takeout printf, then I am not getting those values also. Looklike printf adding the delay.

 

Do I need more delay before selecting chipset and reading ADC input?.

 

 

0 Kudos

614 Views
mjbcswitzerland
Specialist V

Hi

 

The ADC conversion time depends on the ADC speed configured and partly on whether parallel mode is used or not.

 

In any case, check first whether the conversion is complete for each channel in ADC_ADSTAT. If it is not ready you need to wait before reading the value.

 

Regards

 

Mark

 

www.uTasker.com

0 Kudos

614 Views
TVNAIDU
Contributor III

Marc:

 

I added this status check before I read on ADRSLT7, but I can get value only one time, for next readings I am not getting.

 

while (MCF_ADC_ADSTAT & 0xc0000);

 

I added above check before I read MCF_ADC_ADRSLT7 pin for every chip select using AN0-4.

 

0 Kudos

614 Views
mjbcswitzerland
Specialist V

Hi

 

Check yout ADC triggering strategy. Maybe it is operating in one-shot mode and so only returning one sample value.

 

Regards

 

Mark

 

www.uTasker.com

 

0 Kudos

614 Views
TVNAIDU
Contributor III

any sample prog to read single pin AN7 as ADC output by selecting mux using GPIO pins as input. looking for sample prog, appreciated

0 Kudos