ADC problem

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
1,744件の閲覧回数
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.   

ラベル(1)
0 件の賞賛
1 解決策
627件の閲覧回数
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 件の賞賛
4 返答(返信)
628件の閲覧回数
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 件の賞賛
627件の閲覧回数
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 件の賞賛
627件の閲覧回数
mjbcswitzerland
Specialist V

Hi

 

Yes, this is also true.

 

Regards

 

Mark

0 件の賞賛
627件の閲覧回数
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 件の賞賛