What is the best and fastest way to read two 200Hz signals with ADC? on LPC4337

cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best and fastest way to read two 200Hz signals with ADC? on LPC4337

1,099 Views
nataliarequejo
Contributor I

I am writing to see if someone can give me a hand with the ADC on LPC4337

I'm doing a practice in which I have to sample two signals at 200Hz.
I need to sample at least 500 points for each cycle.
Since I know that the LPC4337 ADC have a sampling frequency of 400 KHz I assumed that is possible.

However the maximum speed that achievement, sampling with DMA, ADC0 Channel 2 and ADC1 channel 2,  is 33,8kHz. which represents approximately 169 samples per cycle.
(To reach that number, (33,8KHz) I turn on and turn off a exit pin, when finished reading the 2 ADC and I measure it with an oscilloscope)
If I only activated one channel and one ADC, the actual sample frequency is 79.9 KHz. (Which also remains poorly)

all those test was with BURST Mode disabled. If I configurate the ADC in interruption mode instead of DMA, it is slower yet.

Finally I tryed enabling Burst Mode, and remove the DMA and interrupts.
I made a loop and I kept waiting for the data inside a while (1), Channel 2 and Channel 3 ADC0.

/* Waiting for A/D conversion complete */
while (Chip_ADC_ReadStatus(LPC_ADC0, ADC_CH_SEN, ADC_DR_DONE_STAT) != SET) {}
/* Read ADC value */
Chip_ADC_ReadValue(LPC_ADC0, ADC_CH_SEN, &dataADC0);


Now the frequency is 100KHz approx. almost exactly 500 points per cycle . But as I start to make something, this consume cycles and the frecuency falls, obviously I do not get the amount of points I need.

The ADC is configured with a 400KHz sampling frequency and with 10-bit resolution.
the test were without interfering with the reading of the ADC.

Questions:
What is the best and fastest way to read the two signals with the ADC?
Is it possible to sample faster than 100KHz?
Is this a limitation?
Are there some extra settings I should do?

I also need to read the two signals simultaneously.
Is this possible?
if I use the Channel 2 on ADC0 and the channel 2 on ADC1,
Are the readings simultaneous ? or sampled first one and then the other.

Any help you can give me I would appreciate it. Sorry for my english.
Thank you so much.
Natalia

Tags (2)
0 Kudos
4 Replies

434 Views
rocky_song
NXP Employee
NXP Employee

Hi Natalia,

ADC on LPC43xx has clock divider, and the highest allowed ADC clock rate is 4.5MHz ADC clock. ADC costs 11 cycles per conversion for 10 bit, that is, about 400ksps at max ADC clock rate. So it has no problem to reach 100ksps.

The measurement of conversion rate is not accurate, because it includes other overheads such as IRQ response, pin toggle, and instruction execution.

For your most important question, to sample 2 analog sources at 200Hz simultaneously, you could consider using ADC0 to convert one source, and ADC1 to convert another. For example, connect source 0 to shared ADC channel 0 and let ADC0 to convert this channel, connect source 1 to shared ADC channel 1 and let ADC1 to convert this channel.

To ensure both ADCs start simulatenously, use a timer match signal (E.g., timer0.match0) as hardware trigger source for both ADC (in "CR" register of ADC0 and ADC1, set bitfield [26:24] to 2 or 3).
The timer should be programmed to match at every 5ms (200Hz), make sure to clear its counter on match. Once counter is cleared, timer counts up again from 0, until it reaches match value at the next time, then the next match event occurs and timer counter is cleared again, at the same time, ADC is triggerred. In this manner, both analog source have the same 200Hz time base.
Note: No need to connect the match signal to external pin, match signal are connected to ADC input inside the chip.
Note: GIMA "ADCSTART0_IN" and "ADCSTART1_IN" registers allow more timer match event options. Including T3.MAT3, T0.MAT0, T2.MAT0.
Remark: Do not use burst mode for hardware trigger.

For data fetch, because 200Hz is very low, for simplicity, software can use IRQ mode to fetch sampled data: User code can enable ADC channel IRQ, so IRQ will be fired when a sample is done. Code can enable this IRQ of only one ADC, and fetch data of both channel (provided both ADCs work at the same conversion rate) in ISR.
Remark: Do not read "GDR" register for data fetch, but read DR# (# = 0 to 7), according to the ADC channel connected to analog source, such as ADC0->DR0 and ADC1->DR1.

Best regards

Rocky Song

0 Kudos

434 Views
nataliarequejo
Contributor I

Thank you so much for your reply, I will try what you say. I'll tell you later

0 Kudos

434 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi,

I did a test based on Keil MCB4357 board (OM13040) to test 10-bit ADC module performance.

LPC4357 is same platform product with LPC4337, related 10-bit ADC module feature/performance is totally same.

The MCB4357 ARM Cortex-M4 core clock frequency is 204MHz and ADC sampling frequency configured to 400KSamples/s with 10-bit resolution.

The test code based on LPCOpen software for Keil MCB4300 board V2.20 [adc] demo.

Test result:

ADC conversion value read using interrupt way:

  • Each ADC conversion start to finish ADC conversion value read in related interrupt service routine will take 3.2us;
  • Finish 100K times ADC conversion and read related value in ISR will take 420ms;
  • Enable burst mode,finish one time ADC conversion and read ADC value in ISR will take 3.3us;
  • Enable burst mode, finish 100K times ADC conversion and read related value in ISR will take 248ms;

ADC conversion value read using DMA way:

  • DAM module transfer one ADC conversion value from software trigger ADC conversion will take 3.6us;
  • DMA finish transfer 100K sampling ADC conversion value from software trigger ADC conversion will take 368ms;

ADC0 using DMA transfer conversion value and ADC1 using interrupt way(ADC0/1 work at same time):

  • Finish 100K times ADC conversion for each ADC module will take 452ms.

With above test results, the LPC4337 chip should match with customer requirement.

Thank you for the attention.

Best regards,

Ma Hui

0 Kudos

434 Views
Hui_Ma
NXP TechSupport
NXP TechSupport

Hi

LPC4337 product with core clock up to 204MHz and ADC sampling frequency up to 400Ksamples/s.

Whatever customer using ADC interrupt mode (ADC conversion finished will generate an interrupt, in related interrupt service routine read ADC conversion result) or using ADC DMA mode (ADC conversion finished will trigger DMA transfer related ADC conversion result to memory), the LPC4337 should match with the requirement.

LPC4337 provides two ADC modules with same performance. Customer can operation the two ADC modules simultaneously.

One ADC module using the interrupt way to transfer ADC result, the other ADC module using DMA to transfer ADC result.


Wish it helps.

Have a great day,
Ma Hui
-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos