2022-05-28 03:23 AM
Here
SysTick_Config(16 000 000)
takes one second to count down from 16 000 000 to zero?
That is, one tick has a duration of 1/16 000 000==62.5 ns ?
0.0000000625(one tick time) *16 000 000 ticks== 1 second
Correctly?
At the end of each count, an interruption is made, I know this, I just do not understand what I wrote above.
2022-05-28 05:28 AM
Would depend if SYSCLK is actually 16 MHz, where there are 16,000,000 cycles per second, and each is 1/16,000,000 seconds in duration.
The SysTick typically clocks at HCLK or HCLK/8, and the down count is 24-bits wide
2022-05-28 05:47 AM
I found SYSCLK and HCLK.
Which of these two parameters determines how long one tick will last?
2022-05-28 05:50 AM
>>The SysTick typically clocks at HCLK or HCLK/8, and the down count is 24-bits wide
24 bits is 16 777 215
This is more than 16 megahertz.
I know that the SysTick->LOAD register is 24 bits, but that's more than 16 megahertz.
2022-05-28 06:03 AM
JW
2022-05-28 04:50 PM
I checked with this code what frequency SysTick uses as a reference for the duration of one tick.
#include "main.h"
uint16_t delay_count=0;
void SysTick_Handler(void)
{
if(delay_count>0)
{
delay_count--;
}
}
void delay_ms(uint16_t delay_temp)
{
delay_count=delay_temp;
while(delay_count)
{
}
}
int main(void)
{
RCC->AHB1ENR|=RCC_AHB1ENR_GPIODEN;
GPIOD->MODER|=1<<(2*12);
SysTick_Config(16000000);
while (1)
{
GPIOD->ODR^=(1<<12);
delay_ms(5);
GPIOD->ODR^=(1<<12);
delay_ms(5);
}
}
The SYSCLK frequency is used as a reference for the duration of one tick.
That is, 1 tick is equal in my case to 1/16,000,000=62.5 ns
Probably the System Timer that you showed is also used somehow, I don't know how.
How is the System Timer you showed used?
2022-05-28 05:39 PM
If I change the System Timer to 1 MHz, then the duration of the blinking of the LED does not change, which means that the System Timer most likely does not control the duration of one tick.
However, changing SYSCLK also does not change the blinking duration of the LED.
2022-05-29 05:18 AM
By clicking in CubeMX and using generated code, you should accept that CubeMX "does things".
If you want to understand them, look into those. In other words, read the CubeMX-generated and Cube-provided sources and act accordingly. They are open-source.
Ultimately, the mcu works out of the content of its registers, so if you want to really understand what's going on, read out those registers.
JW
2022-05-29 06:59 AM
@Community member
Cube does not generate code for the divisor of SysTick, at least for one STM32 type.
So if you change it from 1 to 8 and re-generate it may not work.