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

SystemCoreClock variable is updated in two ways only #96

Open
CanastraRF opened this issue Dec 16, 2024 · 3 comments
Open

SystemCoreClock variable is updated in two ways only #96

CanastraRF opened this issue Dec 16, 2024 · 3 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 rcc Reset and Clock Controller

Comments

@CanastraRF
Copy link

Dear Developer
in Drivers/CMSIS/Device/ST/Source/Templates/system_stm32l4xx.c
stands:

The SystemCoreClock variable is updated in three ways:
1) by calling CMSIS function SystemCoreClockUpdate()
2) by calling HAL API function HAL_RCC_GetHCLKFreq()
3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency

But HAL_RCC_GetHCLKFreq() does not update SystemCoreClock

Either fix the doc or the code

BTW:
HAL_RCC_GetSysClockFreq() and SystemCoreClockUpdate() are very similar
Can they merged together?

In HAL_RCC_GetSysClockFreq() are RCC_xxx_Pos used. In SystemCoreClockUpdate() are numerical Values used.
Please use in both case RCC_xxx_Pos.

@ALABSTM ALABSTM added bug Something isn't working hal HAL-LL driver-related issue or pull-request. rcc Reset and Clock Controller labels Dec 18, 2024
@TOUNSTM
Copy link
Contributor

TOUNSTM commented Dec 20, 2024

ST Internal Reference: 199230

@TOUNSTM TOUNSTM moved this from To do to Analyzed in stm32cube-mcu-fw-dashboard Dec 20, 2024
@TOUNSTM TOUNSTM added the internal bug tracker Issue confirmed and logged into the internal bug tracking system label Dec 20, 2024
@CanastraRF
Copy link
Author

BTW. This Problem is also in all other families

@TOUNSTM
Copy link
Contributor

TOUNSTM commented Dec 23, 2024

Hello @CanastraRF,

You have raised three points in this issue, and below are the details:

1. Documentation and Code Discrepancy

Dear Developer in Drivers/CMSIS/Device/ST/Source/Templates/system_stm32l4xx.c stands:

The SystemCoreClock variable is updated in three ways: 1) by calling CMSIS function SystemCoreClockUpdate() 2) by calling HAL API function HAL_RCC_GetHCLKFreq() 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency

But HAL_RCC_GetHCLKFreq() does not update SystemCoreClock

Either fix the doc or the code

We appreciate your observation and have submitted an internal bug tracker to our development team to address this issue. It will be fixed as soon as possible. Additionally, this fix will be cloned across all impacted series to ensure consistency.

2. Merging HAL_RCC_GetSysClockFreq() and SystemCoreClockUpdate()

Regarding your suggestion to merge HAL_RCC_GetSysClockFreq() and SystemCoreClockUpdate(), we respectfully disagree. Although these functions are related, they serve distinct purposes:

  • HAL_RCC_GetSysClockFreq(): This API is part of the HAL library and is used to get the current system clock frequency.

  • SystemCoreClockUpdate(): This API is part of the CMSIS library and is used to update the SystemCoreClock variable.

While both functions deal with the system clock frequency, they should remain separate to maintain clear and efficient code.

3. Use of RCC_xxx_Pos Constants

You also pointed out that HAL_RCC_GetSysClockFreq() uses RCC_xxx_Pos constants, whereas SystemCoreClockUpdate() uses numerical values. We agree that using RCC_xxx_Pos constants in both functions would enhance code readability. However, we currently do not accept this kind of enhancement as it does not affect the functionality of the code.

Thank you for your valuable feedback.
Best regards,

@TOUNSTM TOUNSTM moved this from Analyzed to In progress in stm32cube-mcu-fw-dashboard Dec 23, 2024
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 rcc Reset and Clock Controller
Projects
Status: In progress
Development

No branches or pull requests

3 participants