ADC problem

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

ADC problem

Jump to solution
1,725 Views
dgipling
Contributor I

Hi, I am pretty new to ColdFire CPU and have just started to work with it.  I want to use the ADC converter to do some simple measurments.  I have tried the following code but all that is printed is 0 for all channels.

 

           MCF_ADC_CTRL2 = 0x1F; //slowest possible clock
          
           MCF_ADC_POWER &= ( MCF_ADC_POWER_PD0 |   //power up ADC
                  MCF_ADC_POWER_PD1 |
                  MCF_ADC_POWER_PD2 );
          
           MCF_GPIO_PANPAR = 0xff;   //use adc on AN0-7
          
           MCF_ADC_CTRL1 = 0x2000;  //start convertion single ended once seqential
          
           while ( MCF_ADC_ADSTAT & 0xc000 ); //wait till convertions ready
          
           for ( i = 0; i < 8; i++ )
            printf ( "ADC%d: %x\n", i, MCF_ADC_ADRSLT(i));

 

The CPU is a 52233 using a 25MHz Xtal multipledied with 2 by the PLL to be able to use fast ethernet.   

Labels (1)
0 Kudos
1 Solution
608 Views
mjbcswitzerland
Specialist V

Hi

 

Check the following line:

 

MCF_ADC_POWER &= ( MCF_ADC_POWER_PD0 | MCF_ADC_POWER_PD1 | MCF_ADC_POWER_PD2 );

 

These bits are '1' as default (powered down) so to power them up you need to set them to '0'. That is you need to use &= ~(...)

 

If you need complete ADC support, check out the following: http://www.utasker.com/forum/index.php?topic=280.0. The utasker simulator supports the ADC module and can be used to test threshold triggering interrupts etc...It also automatically optimises the power consumption of the module depending on its exact usage.

 

Regards

 

Mark

 

 

www.uTasker.com
- OS, TCP/IP stack, USB, device drivers and simulator for M521X, M521XX, M5221X, M5222X, M5223X, M5225X. One package does them all - "Embedding it better..."

 

 

View solution in original post

0 Kudos
4 Replies
609 Views
mjbcswitzerland
Specialist V

Hi

 

Check the following line:

 

MCF_ADC_POWER &= ( MCF_ADC_POWER_PD0 | MCF_ADC_POWER_PD1 | MCF_ADC_POWER_PD2 );

 

These bits are '1' as default (powered down) so to power them up you need to set them to '0'. That is you need to use &= ~(...)

 

If you need complete ADC support, check out the following: http://www.utasker.com/forum/index.php?topic=280.0. The utasker simulator supports the ADC module and can be used to test threshold triggering interrupts etc...It also automatically optimises the power consumption of the module depending on its exact usage.

 

Regards

 

Mark

 

 

www.uTasker.com
- OS, TCP/IP stack, USB, device drivers and simulator for M521X, M521XX, M5221X, M5222X, M5223X, M5225X. One package does them all - "Embedding it better..."

 

 

0 Kudos
608 Views
dgipling
Contributor I

Thanks a lot Mark,  I have to read the data sheet more detailed I understand.  I had to add another line of code after I had powered up the ADC by addin the code

 

while (MCF_ADC_POWER & (MCF_ADC_POWER_PSTS0 |

MCF_ADC_POWER_PSTS1 | MCF_ADC_POWER_PSTS2))
           {};

0 Kudos
608 Views
mjbcswitzerland
Specialist V

Hi

 

Yes, this is also true.

 

Regards

 

Mark

0 Kudos
608 Views
TVNAIDU
Contributor III

I am using only AN7 bit for ADC, before checking ADSTAT, I need to start sampling once voltage available on AN7, how can I start sampling?. what register I need to set to start sampling?.

0 Kudos