cancel
Showing results for 
Search instead for 
Did you mean: 

STM32WL55 - ADC conversion time

MichaelMor
Associate II

Hello everyone!

I'm working on STM32WL55JCI7 board and trying to run ADC at the fastest speed (min total conversion time mention on datasheet 0.4uSec) and I don't receive this time.

My configuration is the following:

MichaelMor_0-1687075081305.png

And to measure total time of conversion I'm using GPIO as RT check like the following:

//Turn GPIO on 
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4, GPIO_PIN_SET);
 
// Start ADC conversion, function reutrn
HAL_ADC_Start(&hadc);
 
    /* Wait till conversion is done */
while(LL_ADC_REG_IsConversionOngoing(hadc.Instance) == 0UL);
 
//Turn GPIO off
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4, GPIO_PIN_RESET);
 
Result (via scope) is 2.1uSec total time.
Also my optimization of C/C++ builder setting is optimize for speed.
Any advice how to run ADC at maximum speed?

BTW, when trying to change to Sync clock divide by 1 getting the following error:
MichaelMor_1-1687075306648.png


I'll appreciate your help!

Thanks!

3 REPLIES 3
AScha.3
Chief II

just to do a correct time measurement : put in a set/reset pin without adc() , to see how much time hal functions need.

like this:

//Turn GPIO on 
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4, GPIO_PIN_SET);
 
//Turn GPIO off
HAL_GPIO_WritePin(GPIOC, GPIO_PIN_4, GPIO_PIN_RESET);

 

the adc conv.time is the time(adc+pin set)  - time(pin set) .

If you feel a post has answered your question, please click "Accept as Solution".
MichaelMor
Associate II

But does the way I measured ADC runtime is fine? there is a better/accurate way? like system clock cycles?
I tried, so with ADC I got the following result (GPIO4 connected to scope -1.287uSec)

MichaelMor_0-1687083393591.png

 

and with only set/reset command give me (343nSec):

MichaelMor_1-1687083453233.png

 

So I got 1287 - 343 = ~900nSec = 0.9uSec, still twice then datasheet
How can I reduce it?

>But does the way I measured ADC runtime is fine?

basically - yes. but your ADC-conv.time is including the HAL call time, going sub...return, and the wait-ready-loop, also need some time, to check for adc ready.

so to see the adc-time alone , you should start adc by register access, if possible.

(i did this way: first convert by HAL call; now adc is set ready to run, hal did it. then write to AD_CR -> ADEN bit 1...

try...

>How can I reduce it?

direct register access; but "pure" adc speed you can get only by using DMA to put result to an array, without any cpu start and check ready loops; and simply adc in continuous mode, so running as fast, as it can be.

 

If you feel a post has answered your question, please click "Accept as Solution".