AtomSoft
Well-Known Member
Why am i always going crazy here?
Here is a snippet from the main.c file for a example of SysTick from st. How do they get a 1ms time base from simply dividing the clock by 1000 ?
The time base should be 168Khz or ~6uS
Shouldnt they divide it by 168000 for the time base to be 1ms ? (1khz)
From the release notes:
from the included system_stm32f4xx.c file
Forgive me if i missed something obvious
Here is a snippet from the main.c file for a example of SysTick from st. How do they get a 1ms time base from simply dividing the clock by 1000 ?
The time base should be 168Khz or ~6uS
Shouldnt they divide it by 168000 for the time base to be 1ms ? (1khz)
Code:
//.....
/* Setup SysTick Timer for 1 msec interrupts.
------------------------------------------
1. The SysTick_Config() function is a CMSIS function which configure:
- The SysTick Reload register with value passed as function parameter.
- Configure the SysTick IRQ priority to the lowest value (0x0F).
- Reset the SysTick Counter register.
- Configure the SysTick Counter clock source to be Core Clock Source (HCLK).
- Enable the SysTick Interrupt.
- Start the SysTick Counter.
2. You can change the SysTick Clock source to be HCLK_Div8 by calling the
SysTick_CLKSourceConfig(SysTick_CLKSource_HCLK_Div8) just after the
SysTick_Config() function call. The SysTick_CLKSourceConfig() is defined
inside the misc.c file.
3. You can change the SysTick IRQ priority by calling the
NVIC_SetPriority(SysTick_IRQn,...) just after the SysTick_Config() function
call. The NVIC_SetPriority() is defined inside the core_cm3.h file.
4. To adjust the SysTick time base, use the following formula:
Reload Value = SysTick Counter Clock (Hz) x Desired Time base (s)
- Reload Value is the parameter to be passed for SysTick_Config() function
- Reload Value should not exceed 0xFFFFFF
*/
if (SysTick_Config(SystemCoreClock / 1000))
{
/* Capture error */
while (1);
}
//.....
From the release notes:
This example shows how to configure the SysTick to generate a time base equal to 1 ms. The system clock is set to 168 MHz, the SysTick is clocked by the AHB clock (HCLK).
from the included system_stm32f4xx.c file
* HCLK(Hz) | 168000000
*-----------------------------------------------------------------------------
* AHB Prescaler | 1
*-----------------------------------------------------------------------------
Forgive me if i missed something obvious
Last edited: