2021-12-07 06:10 AM
Currently there is only:
__STATIC_INLINE void LL_ADC_ConfigOverSamplingRatioShift(ADC_TypeDef *ADCx, uint32_t Ratio, uint32_t Shift)
{
MODIFY_REG(ADCx->CFGR2, (ADC_CFGR2_OVSS | ADC_CFGR2_OVSR), (Shift | (((Ratio - 1UL) << ADC_CFGR2_OVSR_Pos))));
}
which does not work for ADC3 on H73x
As workaround I added locally o function like this, which used the correct ADC3 mask for ratio:
static void ADC3_ConfigOverSamplingRatioShift( uint32_t ratio, uint32_t shift )
{
MODIFY_REG(ADC3->CFGR2, (ADC_CFGR2_OVSS | ADC3_CFGR2_OVSR), (shift | (((ratio - 1UL) << ADC3_CFGR2_OVSR_Pos))));
}
Is there another way in the LL libs, that I missed to find?
2021-12-08 02:24 AM
Hello @CA..1 ,
Thank you for having reported this issue.
I added the topic STM32CubeMX to your question in order to increase its chance to be reviewed by our CubeMX experts.
Hi @Khouloud OTHMAN , @Khouloud ZEMMELI , Can you please review this CubeMX issue.
Thanks
Imen
2021-12-16 12:01 AM
Hi @CA..1 ,
After deep check, it appears to be an issue with HAL and not CubeMx tool.
Oversampling Ratio is dependent to ADC instance and IP version:
So that for ADC3 of the STM32H72x/3x, the LL_ADC_ConfigOverSamplingRatioShift() should not modify the ADC_CFGR2 with ADC_CFGR2_OVS, but ADC3_CFGR2_OVS, as you already mentioned here in your post.
In the function LL_ADC_ConfigOverSamplingRatioShift (and corresponding LL_ADC_GetOverSamplingRatio) the CFGR2->OVSR does not handle all cases correctly.
For more details, please have a look at this github link: stm32h7 adc driver oversampling ratio depends on ADC instance #117
The LL_ADC_ConfigOverSamplingRatioShift() function is changed to support Ratio from 1..8 (ADC3) or from 1..10 (meaning oversampling by 2^Ratio)
instead of a value from 1..1024.
Also for the LL_ADC_GetOverSamplingRatio()
An internal ticket number 116019, is already submitted in order to check and fix the coherency of LL functions LL_ADC_ConfigOversamplingRatioShift in the STM32H7 series.
(PS: Internal ticket number 116019, this is an internal tracking number and is not accessible or usable by customers).
Thank you once more for your contribution.
When your question is answered, please close this topic by choosing Select as Best. This will help other users find that answer faster.
Imen