ADC - select pins

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

ADC - select pins

984 Views
embedded_eng_
Contributor III

Hi,

I have a LPC55S16-EVK, and I'm using MCUXpresso IDE.

I'm working on a project that is based on lpcxpresso55s16_dev_composite_cdc_msc_bm demo, And I'm trying to add ADC support.

I want to use pin 11 (ADC0 Channel 3B) and pin 23 (ADC0 Channel 3A).

I soldered pin 11 and pin 23 to external wires that are connected to 2 terminals of the same resistor.

My goal is to measure the voltage drop on this resistor(difference between these 2 pins).

I configured the pins using config tool

Screenshot from 2021-07-13 15-45-46.png

I configured the clock

Screenshot from 2021-07-13 16-03-12.png

Peripheral:

Screenshot from 2021-07-13 17-52-22.png

 

And I copied the driver files (fsl_lpadc.*) from another demo to my drivers directory.

I tried to copy the main function code to my main function (just the relevant parts), and the code compiles, but the reads are wrong.

I read "46164" when I should read GND value.

I guess the problem is that I'm not selecting the correct pin.

How can I select, for example, pin 23 (ADC0 Channel 3A)?

 

#define DEMO_LPADC_BASE                  ADC0
#define DEMO_LPADC_USER_CHANNEL          3U
#define DEMO_LPADC_USER_CMDID            1U

 

 

More generic questions: 

* How can I configure ADC to 16 bit resolution?

* Does the driver can measure the difference between 2 pins? or should I read both and calculate it myself?

* If I should do it myself, how can I define 2 ADC?

* How can I use an internal timer to read the ADC values every X seconds?

 

Thanks

 

Labels (1)
Tags (3)
0 Kudos
Reply
2 Replies

970 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello ,

About ADC channel and 16 bit resolution, you can config in "Conversion commands configuration" :

 

Alice_Yang_0-1626255573970.png

 

If can't get data, recommend first use ADC demo under SDK to test, and select and connect the right pin.

 

BR

Alice

 

0 Kudos
Reply

965 Views
embedded_eng_
Contributor III

Thanks

0 Kudos
Reply