2024-01-22 03:13 AM
Hi, engineers of ST company. I want to consult you a problem about generating code for 'SysTick clock source'.
Let us look at the first picture from documentation PM0215 page 63, there introduces the function of 'SysTick control and status register', and says that the 'CLOCKSOURCE' bit(bit 2) is to select the clock source for SysTick.
Then let us look at the second screenshot from STM32CubeMX-6.1.2, the red highlight rectangle part is used to let us configure which clock source to be used for SysTick, HCLK(HCLK/1) or HCLK/8.
Combine the above two picture, I think if we choose to use HCLK(HCLK/1) for SysTick, then the 'CLOCKSOURCE' bit from 'SysTick control and status register' will be set to 1, and if we choose to use HCLK/8 for SysTick, then the 'CLOCKSOURCE' bit from 'SysTick control and status register' will be set to 0.
If my understanding is correct, then the function of STM32CubeMX to produce code for the 'CLOCKSOURCE' bit might be wrong. Because whether I choose HCLK or HCLK/8 as clock source for SysTick, the 'CLOCKSOURCE' bit from 'SysTick control and status register' is always 1, as demostrated below:
Solved! Go to Solution.
2024-01-22 08:02 AM
Hello again @hexiaole
Could you please try this for me :
-After choosing the HCLK/8 for SysTick and generating the code .
- Add the following lines:
HAL_SYSTICK_Config();
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK_DIV8);
Then check if the CLOCKSOURCE bit =0 or not .
I will be waiting for your feedback.
Thx a lot hexiaole :)
2024-01-22 05:46 AM
Hello @hexiaole
First let me thank you for posting.
Could you please try to use the latest version of CubeMX 6.10.0 and see if the issue still exist.
I will be waiting for your feedback.
Thanks in advance.
Ghofrane
2024-01-22 06:14 AM
Ghofrane, thank you for your immediate reply. I download the STM32CubeMX-6.10.0 and retry the same process, but the problem still exist, as demostrated below:
【1. Confirm the STM32CubeMX version is 6.10.0】
【2. Selecting HCLK(HCLK/1) as the clock source of SysTick and examine the CLOCKSOURCE bit from systick control and status register】
【3. Selecting HCLK/8 as the clock source of SysTick and examine the CLOCKSOURCE bit from systick control and status register】
2024-01-22 08:02 AM
Hello again @hexiaole
Could you please try this for me :
-After choosing the HCLK/8 for SysTick and generating the code .
- Add the following lines:
HAL_SYSTICK_Config();
HAL_SYSTICK_CLKSourceConfig(SYSTICK_CLKSOURCE_HCLK_DIV8);
Then check if the CLOCKSOURCE bit =0 or not .
I will be waiting for your feedback.
Thx a lot hexiaole :)
2024-01-22 08:41 AM
【1. generating code using SysTick with HCLK/8 as clock source】
【2. add suggested codes】
【3. test the CLOCKSOURCE bit】
@Ghofrane GSOURI Thank you Ghofrane. After your detailed instructions, the CLOCKSOURCE bit rightly reflect the configured clock source from CubeMX.
And I want to consult you whether this is a problem you and your team will fix later, or this is a normal steps that we should add manually to our project each time.
2024-01-23 12:50 AM
Hello @hexiaole
Thank you for your contributions.
it has been reported to STM32CubeMX development team .
Internal ticket number:171441(This is an internal tracking number and is not accessible or usable by customers).
I will keep you posted with updates.
If your issue is resolved, please close this post by clicking the "Select as Best" button on the previous answer. This will help other members of the community find this response more quickly.
THX :)
Ghofrane