I'm trying to read Systick timer of MK22FN512VLL12 but found that the timer doesn't go below about 0x00D00000. My code is as below.
//Initialization
SYST_CSR = 0x5u; // enable systick
SYST_RVR = 0x00FFFFFFu; // set reload to maximum 24 bit value
SYST_CVR = 0 ; // Reset SYST_CVR to 0 and force reload
val = 0x009E57FF; //val is uint32_t
while(SYST_CVR > val);
With above value in val, the program is stuck forever in the while loop. If I increase val to 0x00FF05FF, program doesn't get stuck at while loop. Using IAR compiler. Also, tried same code on MK22FN512VLH12 but same behavior. Running core clock at 64MHz and the MCU is in normal running mode always. With above SYST_CSR value, no interrupts occur with Systick.
Please let me know how to resolve this issue and let SYST_CVR reach 0 as mentioned in documentation.
I have tested on my FRDM-K22F, as you see, there is not any problem.
BR
XiangJun Rong
Thanks for your response and trying the code. After your verification, I did further investigation into the system and found another process through interrupts resets the value of SYST_CVR causing the problem I saw. When that interference is removed, the systick works fine.