Skip to main content
Senior III
April 28, 2023
Solved

STM32CubeMX bug: Wrong ADC resolution for STM32L476

  • April 28, 2023
  • 6 replies
  • 2204 views

Hi,

I notice that CubeMx allow choose 16-bit resolution but STM32L476 has range from 6 to 12 bit.


_legacyfs_online_stmicro_images_0693W00000bj2D5QAI.png 

When I generate code I can't compile it:


_legacyfs_online_stmicro_images_0693W00000bj2ESQAY.png
_legacyfs_online_stmicro_images_0693W00000bj283QAA.pngMoreover in datasheet we read on page 1:


_legacyfs_online_stmicro_images_0693W00000bj2EwQAI.png 

but it's only one information about mystic 16-bit resolution :D

This topic has been closed for replies.
Best answer by Kamil Duljas

Pleas look at my first post. CubeMx generate ADC_RESOLUTION_16B that not exist in ADC header for this board .

https://github.com/STMicroelectronics/STM32CubeL4/blob/e691a513a48d0014f201ce35a265cbfca446396d/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_adc.h#L465

6 replies

Peter BENSCH
ST Technical Moderator
April 28, 2023

Well, we are talking about a 12-bit ADC with hardware oversampling.

In the generated code you will find at the very bottom: hadc1.Init.OversamplingMode = DISABLE;, which is set by the CubeMX setting in "ADC_Regular_ConversionMode". You will get 16bit oversampling when enabled.

Does it answer your question?

Regards

/Peter

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
Senior III
April 28, 2023

I don't think so. CubeMx should not generate code that you can't compile it​

Dudo
Peter BENSCH
ST Technical Moderator
April 28, 2023

What does the ability to compile have to do with 16-bit oversampling?

Can't you compile the code?

Do you know how 16-bit oversampling works?

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
ST Technical Moderator
May 2, 2023

Hello All,

Issue confirmed and an internal ticket (ID 150960) is submitted in order to fix this.

(PS: ID 150960 is an internal tracking number and is not accessible or usable by customers).

Thank you for your contribution.

Imen

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Thanks