Why does Adc_Read needs so much time?

Dear community,

I have a Question: Why does Adc_Read() need more than 40-80ms? It also has effect an other thread with higher priority, where i read I²C-Devices for digital in- and output and rises the latancy of that thread, which is a big Problem. If I deactivate Adc reading the I²C thread needs 4-6ms but when I activate it, I have times from 5-50ms. When I look to visual Studio Output it seems, that all Adc-functions load and unload two dll´s (libnvrm.dll, libnvos.dll). Could that be the problem?

Here is a sample Code (I uses all 4 Adc-Channels → complete reading needs up to 400ms):

HANDLE hADC1 = Adc_Init(L"ADC1");
bool cofig01 = Adc_SetConfigInt(hADC1, L"BitResolution", 12, StoreVolatile);
bool cofig05 = Adc_SetConfigInt(hADC1, L"AvgSamples", 10, StoreVolatile);
DWORD ReadValue1 = 0;
int TimeBegin = getMilliCount();
DWORD RetVal = Adc_Read(hADC1, &ReadValue1, 4);
int TimeSpan = getMilliCount(TimeBegin); // Here I messured 40-80ms

I forgot the open function in sample code after Adc_Init.

Dear @Janp,

Thank you for contacting support. I am working on this, will get back you soon.

Dear @Janp,

I am able to reproduce the issue and as you stated the library loading and unloading takes 54ms out of 70ms for the Adc_Read API completion. Could you please wait for a few days, let me try to discuss with internally and get back you.

Which I2c channel you are using in the other thread and it’s priority value? Did you try to set the thread to run on specific processor using CeSetThreadAffinity? Does it make any difference?
If possible, could you please share demo code of reproducible of your issue. Let us try to understand the issue better and will try to provide a solution.

Thank you

Hi raja.tx,

I use I2C1 in the other Thread. Priority is 215. Adc Thread is set to Priority 248.
I’m on holiday at the moment and I will test the other thinks in the next week.

Hi raja.tx

I have tried this with CeSetThreadAffinity and unfortunately did not come to an improvement. Also, I have the new version of CeLibrary V2.3 used and hereby there was no improvement. Is there already an internal assumption why this is so?

Dear @JanP,

Always it will take more time if you connect visual studio debugger and measure the time. We measured the load and unload the module without connected, it was 8ms to 13ms at default CPU frequency(216 Mhz). It is overhead to the ADC reading so decided to move the module loading once at Init and unloaded at Deinit. After this implementation the module loading and unloading is negligible. Please download the preliminary verion of the library

and test at your end and let us know the feedback, is that helping solve the issue.

By default DFS is enabled on the T30, if you really need to set the fastest CPU then run Toradex Task manager tool on the module and go to Performance tab and tick Disable DFS and set GART min value to 1300 and then click set.

Hi Raja,

With the new preliminary version ADC reading works very fine and very fast. Thank you so much.