cancel
Showing results for
Did you mean:
SOLVED

269 Views
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
// START = 001 = Start Conversion Now

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

Tags (2)
1 Solution
9 Views
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:

Hope this will be useful for you.
Best regards!
/Carlos
-----------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------

2 Replies
9 Views
Contributor I

Thank you sir,

We have used fallowing code for intilaising

AD0CR &= 0x00000000; // Clear All Bit Control
AD0CR &= 0xFFFEFFFF; // Busrt = 0 - Conversions are software controlled and reguire 11 clocks
AD0CR &= 0xFFF1FFFF; // CLKS = 000 - 10Bit : 11 Cycle Clock Conversion

We are using 12Mhz Crystal for controller

10 Views
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: