Problem with the ADC

cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with the ADC

58 Views
Nadia
Contributor III
Good morning to you all. I'm working with a LPC54616, I'm trying to read the DC voltage coming from one of its ports, for that I configure the ADC, but I'm not able to measure the voltage. If anyone has experienced this and knows how to solve it. Thank you very much. Best regards.
0 Kudos
5 Replies

53 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Nadia,

Pls refer to the thread:

https://community.nxp.com/t5/LPC-Microcontrollers/LPC54018-Reading-Multiple-ADCs/m-p/1256343#M44521

BTW, we have example code for ADC in SDK package, pls download SDK package from the link:

https://www.nxp.com/design/software/development-software/mcuxpresso-software-and-tools-/mcuxpresso-s...

If you still have issue, pls post your code so that we can have a review or test.

Hope it can help you

BR

Xiangjun Rong

0 Kudos

43 Views
Nadia
Contributor III

Here I attach the code I use, it seems to work but not correctly, I read the values that come in through channels 0, 5 and 6 of the ADC0, and when I have no signal introduced they continue to give a value.

Can anyone tell me what the fault is?

0 Kudos

31 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi,

I think the line is incorrect. Because the ADC0_0 channel is multiplexed with internal temperature and extrnal pin PI0_10.

/* Use the temperature sensor input to channel 0. */
ADC_EnableTemperatureSensor(DEMO_ADC_BASE, true);

As you know that the ADC channel0 is multiplexed with temperature sensor output.

xiangjun_rong_0-1617934065414.png

it should be:

ADC_EnableTemperatureSensor(DEMO_ADC_BASE, false);

 

Secondly, you should configure the PIO0_10 as ADC0_0 with the code:


/* Enables the clock for the IOCON block. 0 = Disable; 1 = Enable.: 0x01u */
CLOCK_EnableClock(kCLOCK_Iocon);

IOCON->PIO[0][10] = ((IOCON->PIO[0][10] &
/* Mask bits to zero which are setting */
(~(IOCON_PIO_FUNC_MASK | IOCON_PIO_MODE_MASK | IOCON_PIO_DIGIMODE_MASK)))

/* Selects pin function.
* : PORT0_10  is configured as ADC0_0. */
| IOCON_PIO_FUNC(PIO016_FUNC_ALT0)

/* Selects function mode (on-chip pull-up/pull-down resistor control).
* : Inactive.
* Inactive (no pull-down/pull-up resistor enabled). */
| IOCON_PIO_MODE(PIO016_MODE_INACTIVE)

/* Select Analog/Digital mode.
* : Analog mode. */
| IOCON_PIO_DIGIMODE(PIO016_DIGIMODE_ANALOG));

Pls have a try.

Anyway, even if you do not connect the ADC0_0 pin(float), you will get a ADC sample, it is possible that the sample is not zero.

Hope it can help you

As a test, I suggest you connect the pin(ADC0_0) to GND or VDD via a serial 5K resistor as a test.

BR

XiangJun Rong

BR

XiangJun Rong

0 Kudos

48 Views
Nadia
Contributor III

I have tried to remove my code and use yours, but it doesn't work, I am only trying to read a DC signal that I input on channel 0 of the ADC.

0 Kudos

38 Views
frank_meyer
Contributor IV

There is no code attached covering the pin initialisation, usually done in pin_mux.c by the SDK code.

I suggest the get the proper SDK (if you haven't already), select a proper example for your MCU/board in MCUxpresso, and build it.

I would recommend one of the ADC examples in driver_examples/adc. The lpc_adc_dma and lpc_adc_interrupt examples worked for me out of the box. I used a LPC54628.

0 Kudos