STM32F3 : ADC => limitation on DEPTH

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
User avatar
alex31
Posts: 374
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 38 times
Been thanked: 61 times
Contact:

STM32F3 : ADC => limitation on DEPTH

Postby alex31 » Thu Jul 27, 2017 3:08 pm

Hello,

I am using ADC on stm32F303 (branch 17.6 stable) , and i wads planning to use 3 channels with a depth of 2, this configuration works on STM32F4

On the F3, the mcu hangs in internal dma routines, until a raise depth to 12.

I have seen that in the testhal directory, depth is alway more or equal to 16 in continuous mode.

Is this an hardware DMA limitation, or a ChibiOS driver one ?

Another solution for me would be to start a conversion in an ISR, and use the result in another ISR, but the adcConvert api does not permit to
initiate a single conversion from ISR.

Alexandre

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: STM32F3 : ADC => limitation on DEPTH

Postby Giovanni » Fri Jul 28, 2017 9:34 am

Hi,

Low depths cause more frequent interrupts, depth must be large enough to let CPU serve callbacks.

Giovanni

User avatar
alex31
Posts: 374
Joined: Fri May 25, 2012 10:23 am
Location: toulouse, france
Has thanked: 38 times
Been thanked: 61 times
Contact:

Re: STM32F3 : ADC => limitation on DEPTH

Postby alex31 » Fri Jul 28, 2017 1:05 pm

Yes, thanks, that was the problem.

I have fixed my problem launching startAdcConversion in an ISR to start conversion only in the window time where i need to sample data.

I didn't do that before, but i discover that if i set field circular to false, and (in case of adcV3) bit ADC_CFGR_CONT not set in CFGR register,
startAdcConversion will launch just one conversion with ISR triggered at end of conversion, and it's just what i needed :-)

since i do only one conversion, i can even have DEPTH set to 1.

MCU no more hangs, and memory bandwidth is no wasted by useless DMA transfert.

It's the first time i use stm32F3, (used to F4 and F7), and performance is much lower on F3, on a severely jitter constrained application (brushless sensorless motor controller), every possible optimization count ...

Alexandre

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: STM32F3 : ADC => limitation on DEPTH

Postby Giovanni » Fri Jul 28, 2017 1:49 pm

Yes, one must be careful only with circular conversions.

Giovanni

AdShea
Posts: 6
Joined: Mon Nov 30, 2015 9:03 pm
Has thanked: 1 time
Been thanked: 2 times

Re: STM32F3 : ADC => limitation on DEPTH

Postby AdShea » Tue May 22, 2018 4:17 pm

I've run into similar issues (using an F4) and have my own patched hal_adc.c that gets rid of the even depth requirement as I'm running triple ADC with 3 conversions each (depth = 3) but using direct triggering from the TIM2_TRGO event (while TIM2 is triggered by TIM1_TRGO to allow placing the sample start precisely). ChibiOS doesn't know about this so it looks like I'm asking for short continuous conversions, but what really happens is that when the timer triggers it does 9 conversions across the three ADCs then triggers an interrupt.

It'd be nice to add hardware triggering to the HAL as most mid-range and higher MCUs have it and it's essential for low-jitter sampling, but I'm not sure quite how to do so in a platform-agnostic way.

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: STM32F3 : ADC => limitation on DEPTH

Postby Giovanni » Tue May 22, 2018 5:25 pm

Hi,

There are already HW triggered demos under testhal using a GPT as trigger for an ADC.

Giovanni


Return to “ChibiOS/HAL”

Who is online

Users browsing this forum: No registered users and 8 guests