frdmkv31f - ADC Performance

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

frdmkv31f - ADC Performance

1,915 Views
shai_b
Senior Contributor II

Hello Team,

I am trying to help my customer to achieve higher speed on the ADC peripheral, Could you please advise how can I get the maximum sampling time into the KV31P100M120SF7.
According to the datasheet, the maximum sampling in 12-bit is 1.2MS/s.

frdmkv31f_adc.jpg

I made few tests to check the performance of the ADC and MCU functionality and got different numbers.

1. ADC get value in polling mode (12 or 10bit) = 3.128µsec
2. Set channel config by using function ADC16_SetChannelConfig = 0.448µsec

Please find below my ADC configuration and I'm using with 120MHz system clock (BOARD_BootClockHSRUN):

adc16ConfigStruct.clockSource = kADC16_ClockSourceAlt0;

adc16ConfigStruct.hardwareAverageMode = kADC16_HardwareAverageDisabled;

adc16ConfigStruct.resolution = kADC16_ResolutionSE12Bit;

adc16ConfigStruct.clockDivider = kADC16_ClockDivider1;

adc16ConfigStruct.longSampleMode = kADC16_LongSampleDisabled;

adc16ConfigStruct.enableHighSpeed = true;

adc16ConfigStruct.enableContinuousConversion = true;

adc16ConfigStruct.enableAsynchronousClock = false;

 

Please advise how can we improve the ADC sampling time to <1µsec?

Waiting for your kind response, Thanks.

Best Regards,

Shai

Tags (2)
0 Kudos
11 Replies

1,899 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

Hi Shai,

According to the datasheet, you need to configure:
fADCK(ADC conversion clock frequency)=24MHz
12bit mode
CFG2[ADHSC] must be set and CFG1[ADLPC] must be clear

1200Ksps 12bit ADC Continuous conversions enabled, subsequent conversion time.jpg

Then you will get the 1200 Ksps Crate(ADC conversionrate).
Notice: No ADC hardware averaging Continuous conversions enabled, subsequent conversion time

 

Please check whether the ADC clock source in your configuration can be divided to 24MHz.
According to your codes, I can see you configure the Core clock to 120MHz.
But I don't know the frequency of Bus clock.(I am afraid 120MHz MCGOUTCLK can't divide to 48MHz or 24MHz Bus clock)
It caused you can't achieve 1200 Ksps ADC.

Maybe you can try to select kADC16_ClockDivider2:
use IRC48M as ADC clock
or
configure 96MHz MCGOUTCLK and 48MHz Bus clock, select Bus clock as ADC clock source.

 

Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

0 Kudos

1,882 Views
shai_b
Senior Contributor II

Dear @Robin_Shen,

Thanks for the info and support.

I've created a project from scratch and added the relevant drivers.

I changed the ADC configuration according to your suggestion.

Now, ADC sampling time is around 2.5usec and if I change the divider to 1 it was improved to 2usec (but it’s not like the recommendation).

Be noted, If it would assist I can share with you the customer project for review.

 

In addition, the example project of ADC polling mode contains the following condition for the end of conversion.

 

while (0U == (kADC16_ChannelConversionDoneFlag &

ADC16_GetChannelStatusFlags(DEMO_ADC16_BASE, DEMO_ADC16_CHANNEL_GROUP)))

                                {

                                }

 

Is it enough to wait only to  kADC16_ChannelConversionDoneFlag? If yes, the ADC sampling time will improve to 1u.

 

One more question, what is the fast way to read and set the GPIO?

The function of GPIO_PinWrite takes around – ~0.4µsec (while working MCGOUTCLK as 120MHz).

 

Waiting for your feedback, Thanks in advance.

Kind regards,

Shai

0 Kudos

1,853 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

I think you can refer frdmkv31f_adc16_continuous_edma example instead of frdmkv31f_adc16_polling.


Would you please let me know the clock source of ADC that you selected? (IRC48M or 120MHz MCGOUTCLK)
If you select MCGOUTCLK as clock source of ADC, MCGOUTCLK should be configured 96MHz in order to get 24MHz fADCK.

GPIO_PinWrite will determine whether to set or clear, maybe you can direct write the PCOR or PSOR register.(But I don't think it will not reduce too much time consumption)

GPIO_PinWrite.jpg
What is the purpose of GPIO operation? If you just want to observe the ADC sampling frequency, you can refer verify ADC conversion rate with oscilloscope.

0 Kudos

1,845 Views
shai_b
Senior Contributor II

@Robin_Shen ,

The customer used the IRC48M as a clock source of ADC, he will try to use the adc16_continuous_edma example demo to see if he can achieve 1 usec.

BTW, Did you managed to achieve 1 usec with frdmkv31f MCU?

Thanks in advance 

Shai 

0 Kudos

1,838 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

I used the Processor Expert tool in KDS to configure a simple test project to quickly verify the ADC sampling frequency. (The ADC clock source is Bus Clock, which is divided down to 24MHz for ADC use)

24MHz ADC clock.jpgNewFile0.bmp

0 Kudos

1,832 Views
shai_b
Senior Contributor II

@Robin_Shen,

Thank you so much for your great support, the customer works with MCUexpresso and he tried to use the internal IRC48M as the ADC clock source.

But without a success, I can share the project if needed.

BTW, I do not familiar with KDS, and if it possible that you will provide me your project so the customer would try it on its own (preferred in MCUexpresso format).

secondly and more important could you please elaborate more about the figure of the scope, for example, what did you measure and how did you perform the test in order to get the 920 nsec results output?

Thanks in advance 

Kind regards,

Shai

0 Kudos

1,814 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

For more detail about the the figure of the scope, you may need to read verify ADC conversion rate with oscilloscope.

The probe of oscilloscope is connect at ADC0_DP0_RC(Pin5 J2) of FRDM-KV31F board.

1622188447576.jpg

0 Kudos

1,776 Views
shai_b
Senior Contributor II

Dear @Robin_Shen,

Thanks for your great support and info.
There is bad and good news.

The bad news is that I made the same test as below and didn’t get the figures that you achieved.
I was using with 2K resistor and ADC0_SE8 pin.
I would be happy to understand what am I missing.

frdmkv31f_scope.jpgfrdmkv31f_scope2.jpg

 

 

 

 

 

 

 

 

 

 

The good news is that when I bypass the function of the GPIO driver and set\get directly from the registers the TP time is improved.

For example, the GPIO_PinWrite function takes around 500nSec but when I set the IO directly from the registers is takes 160nSec.

520nSec -> GPIO_PinWrite(BOARD_DBG_GPIO, BOARD_DBG_GPIO_PIN, LOGIC_HIGH);

160nSec -> BOARD_DBG_GPIO->PSOR = GPIO_FIT_REG(u32flag << BOARD_DBG_GPIO_PIN);

 

Waiting for your kind comment on how I can reach a better conversion time as you managed to reach?

Thanks in advance

BR,

Shai 

0 Kudos

1,765 Views
Robin_Shen
NXP TechSupport
NXP TechSupport

I modify the  frdmkv31f_adc16_continuous_edma based on SDK_2.9.0_FRDM-KV31F with MCUXpresso IDE v11.3.1_5262.

You can refer the modification shown below:

MCG PLL FLL IRC48M clock.jpgfrdmkv31f_adc16_continuous_edma.jpg1623055724683.jpg

notice the setting of oscilloscope: AC 20mV 920ns.bmp

Customer can direct test the attached project.

Best Regards,
Robin
-------------------------------------------------------------------------------
Note:
- If this post answers your question, please click the "Mark Correct" button. Thank you!

- We are following threads for 7 weeks after the last post, later replies are ignored
Please open a new thread and refer to the closed one, if you have a related question at a later point in time.
-------------------------------------------------------------------------------

1,758 Views
shai_b
Senior Contributor II

@Robin_Shen , Thank you so much.

I will keep you posted as needed.

KR,

Shai

0 Kudos

1,891 Views
shai_b
Senior Contributor II

@Robin_Shen Hello,

Thank you for your inputs, I'll follow your point-out and advise you back (if needed).

Thanks in advance

BR,

Shai

0 Kudos