2025-01-17 04:37 AM
I'm searching for super coding comfort in CubeIDE. Currently TIM2 resets/updates.
In HAL_TIM_PeriodElapsedCallback() I "manually" start HAL_ADC_Start_DMA() the Scan conversion of four channels and have the four results shipped into my progs memory, via DMA. Works like a charm.
But there is the mighty diagram (Fig.31) on p.213 of the STM32F411CEU6 reference manual,
clearly showing that ther are alternatives to starting the ADC manually via software.
Among a lot of options there is TIM2_TRGO or TIM2_CHx configurable as ADC trigger input.
So, is the following possible:
1) TIM2 loops indefinitely at a speed configured by me after being started once in main().
2) At every interation TIM2 triggers the start of the ADC (HOW?).
3) The ADC is configured to convert 4 channels.
4) The ADC is configuired to ship the result of every conversion to my memory via DMA.
Currently I've no idea how to click / dropdwon CubeIDE to get 2) working.
The result would be very cool:
no callbacks at all, all steps in that process chain done automagically,
the software coder simply has to look at DMA destination buffers, and do his thing.
2025-01-17 07:45 AM
2025-01-17 08:16 AM
Nice examples, thx!
I found TIM2 settings :
/* Set timer the trigger output (TRGO) */
LL_TIM_SetTriggerOutput(TIM2, LL_TIM_TRGO_UPDATE);
/* Enable counter */
LL_TIM_EnableCounter(TIM2);
sounds familiar, but directly via the LowLevel interface routines. TIM2_TRGO UPDATE is set.
There are ADC Setting, too:
/* Set ADC group regular trigger source */
LL_ADC_REG_SetTriggerSource(ADC1, LL_ADC_REG_TRIG_EXT_TIM2_TRGO);
So the TIM2 Output is set to TRGO_UPDATE and the ADC is set to have TIM2_TRGO as trigger source.
=> Exaclty what I tried in CubeIDE (CubeMX confgiured, I think) but no data delivered.
Question is what / where to click in CubeIDE HAL-config to setup both
TIM2_TRGO_UPDATE and ADC trigger_source TIM2_TRGO
2025-01-17 08:28 AM
There are only three HAL_ADC_Start routines: polling, IT (Interrupt) and DMA.
Somehow I'm missing "HAL_ADC_Start_trigger" or "HAL_ADC_Start_TIM2TRGO" .
If I comment out the HAL_ADC_Start_DMA in the TIM2 interrupt routine, and only do one single HAL_ADC_Start_DMA right befor the "main loop"
I get exactly one setup of conversions, and nothing exlse although the TIM2 happily counter and overflows etc
2025-01-17 08:57 AM
There is no such option like set both. I even can't find to set TIM2_TRGO in the timer's sub-menu tabs. Regarding setting linked two lines timer-trgo And adc-trigger, feature wouldn't make sense if more than one timer has active trigger line or many adc linked to different triggers, so this linkage delegated to programmer, to set it "manually".