LPC55S16 ADC with multiple trigger commands

cancel
Showing results for 
Search instead for 
Did you mean: 

LPC55S16 ADC with multiple trigger commands

Jump to solution
436 Views
janpieterderuit
Contributor IV

Hi,

I have some trouble with the ADC on the LPC55S16.

Our usecase:

  • Using the internal temperature
  • Using several ADC channels, both A side and B side (all in single ended mode).

For easy integrating in our current codebase, we want to:

  • Have a trigger command for each individual ADC channel
  • Trigger the command individually (by our SW)
  • Use polling to get the ADC result.

When I implemented this, the ADC values were jumping all over the place, like they ended up in the wrong (random) ADC variables.

E.g.: when I did 3 channels (ADC0, ADC1, ADC2), the results were like:

valueADC0valueADC1valueADC2
ADC1ADC0ADC2
ADC0ADC2ADC1
ADC2ADC1ADC0
ADC1ADC0ADC2
ADC0ADC2ADC1

 

So I tried to reproduce this on me LPCXpresso55S16 development board.
I used the lpadc_temperature_measurement example as basis, with the following changes:

  • I removed the GETCHAR() macro, and replaced it with a 1 second delay (to get results continuously, like in our application)
  • Removed the interrupt handling, and made it polling (copied from lpadc_polling example)
  • Used the CommandID also as TriggerID (so I could easily distinguish later between several ADC channels)
  • Created a seperate function for the channel configuration, which I could easily copy later on for other channels.

After those changes the example still worked correctly (although temperature measurement needs some additional work, as there is a lot of digital noise due to low resolution of the vbe ADC values, but that's another topic):

janpieterderuit_0-1639489562559.png

Now I added ADC channel ADC0_0 (PIO0_23):

  • Added pin config in pinmux.c (copied from lpadc_polling example)
  • Copied the Temperature sensor config function (mentioned above), and changed it for ADC0_0:
    • channelNumber = 0
    • sampleChannelMode = kLPADC_SampleChannelSingleEndSideA
    • New CommandID (2) and also use it as triggerID
    • loopCount = 0
  • After the Temperature sensor trigger and getting the temperature, I added a new trigger (LPADC_DoSoftwareTrigger) with the new triggerID (mask).
  • Added the result to the terminal output.

This is what I get:

janpieterderuit_1-1639490158376.png

As you can see the first temperature result looks OK, but after that it's way off.
(I didn't check the ADC0_0 result, but that also looks off, as nothing is connected to the pin yet)

I attached my MCUXpresso project, can you please have a look what I'm doing wrong?
I can't find any example using multiple channels or ADC commands.
I can't figure it out...
It looks like there's something going wrong in the FIFO, but I can only see the top value...

Thanks in advance.

Best regards

Labels (1)
Tags (3)
0 Kudos
1 Solution
382 Views
janpieterderuit
Contributor IV

Hi Alice,

thanks for your reply.

In my example I have different commands and triggers for each channel, and I also do call seperate triggers.

Anyway, I found the issue:
in the past we found that a trigger was missed somehow occasionally.
This resulted in an infinite wait for the conversion result (with ultimately a watchdog reset).

We fixed this by adding a timeout for the while loop which gets the conversion result.
We set the timeout max at 255 cycles, which is good enough for normal ADC measurements.

However, I found that the internal temperature measurement can take about 4500 cycles (CPU running at 96MHz and ADC clock of 4MHz).
I suppose this is probably because of the hardware averaging used by the internal temperature measurement (we do not do HW averaging on the normal ADC measurements).

So the conversion while loop for the internal temp measurement was aborted due to the timeout, but the FIFO was later on still filled with the temperature values (vbe1/vbe8).
And those values ended up later on when the normal ADC channel measurement is triggered.

I now fixed it by increasing the timeout max to 10000.

Thanks for your effort.

View solution in original post

Tags (1)
0 Kudos
4 Replies
417 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

There is Multiple ADC demo you can compare to have a look :

 

https://community.nxp.com/t5/LPC-Microcontrollers-Knowledge/ADC-multi-channel-sampling-and-DMA-trans... 

 

BR

Alice

0 Kudos
413 Views
janpieterderuit
Contributor IV

Hi,

thanks, I found that one indeed.
But:

  • It does several measurements in one trigger, while we want individual triggers for each measurement
  • It doesn't include internal temperature measurement (and I suspect it's related to that)

BR, Jan Pieter

0 Kudos
388 Views
Alice_Yang
NXP TechSupport
NXP TechSupport

Hello,

You said want individual triggers for each measurement, from your  result , I think in your project, one triggered three channels.

 

BR

Alice

0 Kudos
383 Views
janpieterderuit
Contributor IV

Hi Alice,

thanks for your reply.

In my example I have different commands and triggers for each channel, and I also do call seperate triggers.

Anyway, I found the issue:
in the past we found that a trigger was missed somehow occasionally.
This resulted in an infinite wait for the conversion result (with ultimately a watchdog reset).

We fixed this by adding a timeout for the while loop which gets the conversion result.
We set the timeout max at 255 cycles, which is good enough for normal ADC measurements.

However, I found that the internal temperature measurement can take about 4500 cycles (CPU running at 96MHz and ADC clock of 4MHz).
I suppose this is probably because of the hardware averaging used by the internal temperature measurement (we do not do HW averaging on the normal ADC measurements).

So the conversion while loop for the internal temp measurement was aborted due to the timeout, but the FIFO was later on still filled with the temperature values (vbe1/vbe8).
And those values ended up later on when the normal ADC channel measurement is triggered.

I now fixed it by increasing the timeout max to 10000.

Thanks for your effort.

Tags (1)
0 Kudos