FRDM-MCXN947 sysTick basic

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

FRDM-MCXN947 sysTick basic

238 Views
saulius1005
Contributor II

Today I start to play with sysTick() Timer and trying to make simple code to generate simple output signal

simplest code possible:Ekrano kopija 2024-03-28 120609.png

 

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:

Ekrano kopija 2024-03-28 120635.png

 

what i am doing wrong? 

 

Labels (3)
0 Kudos
1 Reply

210 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

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:

xiangjun_rong_0-1711679372832.png

 

Hope it can help you

BR

XiangJun Rong

0 Kudos