2023-06-18 01:03 AM
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:
And to measure total time of conversion I'm using GPIO as RT check like the following:
I'll appreciate your help!
Thanks!
2023-06-18 02:00 AM - edited 2023-06-18 02:01 AM
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) .
2023-06-18 02:14 AM - edited 2023-06-18 03:18 AM
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)
and with only set/reset command give me (343nSec):
So I got 1287 - 343 = ~900nSec = 0.9uSec, still twice then datasheet
How can I reduce it?
2023-06-18 03:43 AM - edited 2023-06-18 03:52 AM
>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.