Today I start to play with sysTick() Timer and trying to make simple code to generate simple output signal
simplest code possible:
and problem is no matter how much I changing clock frequency value (12Mhz or 150Mhz)output signal is all time the same (interrupt period) ~827kHz.
clock selection from default values at config tools:
what i am doing wrong?
Hi,
As you know that the systick module interrupt period is dependent on the driving clock and SysTick Reload Value Register, which functions as a divider
systick period=driving_clock/Reload_Value
Peripheral Configuration tools can adjust the Reload_Value in SysTick Reload Value Register based on the driving clock so that it can get the constant period you has defined.
I suppose that you can call the function directly which set the SysTick Reload Value Register and enable the systick:
__STATIC_INLINE uint32_t SysTick_Config(uint32_t ticks)
{
if ((ticks - 1UL) > SysTick_LOAD_RELOAD_Msk)
{
return (1UL); /* Reload value impossible */
}
SysTick->LOAD = (uint32_t)(ticks - 1UL); /* set reload register */
NVIC_SetPriority (SysTick_IRQn, (1UL << __NVIC_PRIO_BITS) - 1UL); /* set Priority for Systick Interrupt */
SysTick->VAL = 0UL; /* Load the SysTick Counter Value */
SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
SysTick_CTRL_TICKINT_Msk |
SysTick_CTRL_ENABLE_Msk; /* Enable SysTick IRQ and SysTick Timer */
return (0UL); /* Function successful */
}
This is systick module clock source:
Hope it can help you
BR
XiangJun Rong