2024-06-19 06:56 AM - edited 2024-06-19 06:57 AM
For my project I'm using an STM32L476 MCU with CubeIDE 1.15.1 and CubeMX 6.11.1
In this project I'm using ThreadX / Azure RTOS.
For a new feature I doubled the speed of the MSI, which doubles the system clock, but the HCLK stays the same (by changing the prescaler).
Now when I click regenerate code in CubeMX, the values for the systick are doubled in the tx_initialize_low_level.s
So as an overview
Old value | New value | |
MSI | 1 MHz | 2 MHz |
SysClk | 1 MHz | 2 MHz |
HClk | 1 MHz | 1 MHz |
SYSTEM_CLOCK var in tx_initialize_low_level.s | 1 MHz | 2 MHz |
The SYSTEM_CLOCK var in tx_initialize_low_level.s is used to configure the SysTick.
To me this looks like a bug in the generator as the System clock does not affect the SysTick (the HClk does)?
2024-06-20 08:09 AM
Hello @EmbDev,
As indicated in the tx_initialize_low_level.s description, the _tx_initialize_low_level function is responsible for configuring the SysTick timer to generate periodic interrupts. the SYSTEM_CLOCK must correspond to the system clock
If you want to change the ThreadX tick, you can always change SYSTICK_CYCLES definition in tx_initialize_low_level.S : SYSTICK_CYCLES = ((SYSTEM_CLOCK / 1000) -1), of course, TX_TIMER_TICK_PER_SECOND must also be updated.
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.
2024-06-24 01:08 AM
Thanks Sarra, for me it's confusing to calculate / configure the SysTick timer using the System Clock instead of the Hardware clock.
The SysTick is directly driven by the Hardware Clock, so the calculation is done with an irrelevant value/clock.
When the System Clock is used in the calculation, I can indeed use the TX_TIMER_TICK_PER_SECOND variable to change the division for the SYSTICK_CYCLES (the division is generated by CubeMX so should not be manually changed). The TX_TIMER_TICK_PER_SECOND value (in the CubeMx configuration) is used for both the variable (in the tx_user.h) and the calculation (the value 1000 in the example above). In this case I have a value that is related to the system clock, so I cannot use this variable (TX_TIMER_TICK_PER_SECOND) anywhere else as it is incorrect.
Example:
System Clock 2 MHz, Hardware Clock 1 MHz
To get 1000 ticks per second, TX_TIMER_TICK_PER_SECOND is set to 2000 (2MHz / 2000 = 1000)
The actual value of TX_TIMER_TICK_PER_SECOND should be 1000 as the Hardware Clock is 1 MHz.
What am I missing here? What is the reason to use the completely irrelevant System Clock in this calculation?
2024-07-01 03:06 AM
Can anyone explain / help me with this issue ( @Sarra.S ) ?
2024-07-02 03:22 AM
Hello @EmbDev,
Sorry for the confusion, you are right!
I tested it first with a nucleoU575 having it onboard, this issue wasn't reproduced
but with STM32L476 MCU I can confirm this issue, systick should be driven by the hardware clock HCLK, but in this case, it's driven by sysclk when AHB>1
I've reported this issue to the CubeMX team (Internal ticket number: 185523), I will keep you updated!
Thank you!
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.
2024-09-16 12:57 AM
Hello @Sarra.S , is there any update on this issue? Or any expected timeline?
2024-09-17 02:55 AM
Hello @EmbDev,
I am actively pushing internally for updates on this issue, if there are any, I will inform you promptly
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.