adc problem in LPC2148

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

adc problem in LPC2148

ソリューションへジャンプ
1,320件の閲覧回数
jagadeshwarredd
Contributor I

Hi,

we are using ADC0 to measure voltage of a sensor which gives output 4 to 40mamp.

But sometimes the ADC conversion is not wokring.it is wiaitng at conversion only.

The code what we are using is 

PINSEL1 |= 0x01000000; // channel 0 in adc0
AD0CR &= 0xffffff00;
AD0CR |= 0x00000002; // Select ADC = AD0.1
// START = 001 = Start Conversion Now
AD0CR |= 0x01000000;

while((AD0DR1 & 0x80000000) == 0); // Wait ADC Conversion to Complete and Read A/D Data Register

val = (unsigned int)(AD0DR1 >> 6) & 0x000003FF;
AD0CR &= 0xF8FFFFFF;
return (val);

Please help us in this issue.

thank you in advance 

タグ(2)
0 件の賞賛
返信
1 解決策
1,060件の閲覧回数
CarlosCasillas
NXP Employee
NXP Employee

Hi,

According with your code, most of the initialization seems to be good. However, it doesn’t show the clock reference, as the ADC clock divisor is set to divide by 1, and, by spec, the ADC clock must be lees or equal to 4.5 MHz; besides, the PDN bit is not set on the code, which means that the ADC will not be operational, so, you should verify that.

Additionally, are you running the code on an infinite loop? Because the general recommendation is setting pins/clocks first and then, just launching the conversion and waiting for the competition on the infinite loop.

As complementary info, you could take a look at the following page:

http://www.ocfreaks.com/lpc2148-adc-programming-tutorial/

Hope this will be useful for you.
Best regards!
/Carlos
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

元の投稿で解決策を見る

0 件の賞賛
返信
2 返答(返信)
1,060件の閲覧回数
jagadeshwarredd
Contributor I

Thank you sir,

We have used fallowing code for intilaising 

AD0CR &= 0x00000000; // Clear All Bit Control
AD0CR |= 0x00000400; // ADC Clock = VPB(PCLK) / 8
AD0CR &= 0xFFFEFFFF; // Busrt = 0 - Conversions are software controlled and reguire 11 clocks
AD0CR &= 0xFFF1FFFF; // CLKS = 000 - 10Bit : 11 Cycle Clock Conversion
AD0CR |= 0x00200000;

We are using 12Mhz Crystal for controller

0 件の賞賛
返信
1,061件の閲覧回数
CarlosCasillas
NXP Employee
NXP Employee

Hi,

According with your code, most of the initialization seems to be good. However, it doesn’t show the clock reference, as the ADC clock divisor is set to divide by 1, and, by spec, the ADC clock must be lees or equal to 4.5 MHz; besides, the PDN bit is not set on the code, which means that the ADC will not be operational, so, you should verify that.

Additionally, are you running the code on an infinite loop? Because the general recommendation is setting pins/clocks first and then, just launching the conversion and waiting for the competition on the infinite loop.

As complementary info, you could take a look at the following page:

http://www.ocfreaks.com/lpc2148-adc-programming-tutorial/

Hope this will be useful for you.
Best regards!
/Carlos
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 件の賞賛
返信