Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data filters in LL_ADC_REG_ReadConversionDataX prevent left alignment from working #3

Open
phileimer opened this issue Dec 26, 2023 · 5 comments
Assignees
Labels
bug Something isn't working hal HAL-LL driver-related issue or pull-request. internal bug tracker Issue confirmed and logged into the internal bug tracking system

Comments

@phileimer
Copy link

phileimer commented Dec 26, 2023

Describe the set-up
Any board.
Any IDE/compiler.
Noticed with MC Library with HAL/LL that uses ADC value left alignment.

Describe the bug
In recent version of HAL/LL for G0, functions LL_ADC_REG_ReadConversionData12, LL_ADC_REG_ReadConversionData10, LL_ADC_REG_ReadConversionData8 and LL_ADC_REG_ReadConversionData6 were modified with data filters, respectively 0x00000FFFUL, 0x000003FFUL, 0x000000FFUL, and 0x0000003FUL.
This prevent them from working when LL_ADC_DATA_ALIGN_LEFT is configured.

How To Reproduce
Any project using MC Library or LL_ADC_DATA_ALIGN_LEFT with G0/HAL_LL.

Additional context
Removing the filters mentioned above solves the issue.
For example, for 12 bit data value, the correct function is:

__STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(const ADC_TypeDef *ADCx)
{
  return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
}

@ALABSTM ALABSTM added bug Something isn't working hal HAL-LL driver-related issue or pull-request. labels Dec 28, 2023
@RJMSTM
Copy link
Contributor

RJMSTM commented Dec 29, 2023

ST Internal Reference: 169678

@RJMSTM RJMSTM added the internal bug tracker Issue confirmed and logged into the internal bug tracking system label Dec 29, 2023
@RJMSTM
Copy link
Contributor

RJMSTM commented Jan 5, 2024

Hello @phileimer,

This not a bug:
the feature "data alignment" shifts data to be aligned on bit 15, therefore data is 16 bits wide [15; 0].
And therefore, to read data, function LL_ADC_REG_ReadConversionData32() must be used.

The other functions ..._ReadConversionData6/8/10/12 are not usable in this mode.

An update description will be made of LL_ADC_REG_ReadConversionData32() to be more generic on use cases.

With regards,
Rania

@phileimer
Copy link
Author

Hi Rania (@RJMSTM),

Thank you for your feedback. I got the point.
I believe you should fill in a bug for this in the X-CUBE-MCSDK project.
In its version 5, this project uses left data alignement and the 12 bit function, triggering a severe bug.
I've not checked with the newer version 6.

Also, I noticed these LL_ADC functions for other STM32 flavors I use (F4 and L0) don't have these data filters implemented yet.
Will they be modified later?

Thank you again,
J. Ph.

@FredericVirot
Copy link

Hello Jean-Philippe (@phileimer),

X-CUBE-MCSDK version 6.x also uses a left alignment configuration for the ADCs, so this issue is present in this line of versions. This indeed causes a severe bug as it makes the MCSDK unusable on G0 with the 1.6.2 version of the G0 LL drivers.
This issue will be addressed soon in an upcoming version of MCSDK 6.x.
However, note that X-CUBE-MCSDK version 5 will most probably not be updated to fix this issue. I would strongly advise you to switch to X-CUBE-MCSDK version 6.x.

The other STM32 series are not currently touched by this issue.

With my best regards,

Fred.

@phileimer
Copy link
Author

Hi Fred,
Thank you for your feedback.
I already fixed this issue in my MCSDK v5 for G0 projects.
These are unlikely to be switched to v6 because they are mature.
Merci bien,
J. Ph.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working hal HAL-LL driver-related issue or pull-request. internal bug tracker Issue confirmed and logged into the internal bug tracking system
Projects
Status: In progress
Development

No branches or pull requests

4 participants