AnsweredAssumed Answered

[newbie] how to use systick?

Question asked by shan on Mar 5, 2014
Latest reply on Mar 5, 2014 by shan
Hi all,

I saw many examples using systick interrupt handler to generate the accurate delay time (like the example below).  My question would be pretty simple here:  why does "SysTick_Config(SystemCoreClock / 1000)" generate a 1 millisecond delay?  I need to examine the execution time of each section of my code in my project, which might reach to microsecond level, so I'm trying to understand the systick time calculation.  

#include "LPC17xx.h"
uint32_t msTicks = 0;                                       /* Variable to store millisecond ticks */
void SysTick_Handler(void)  {                               /* SysTick interrupt Handler.
  msTicks++;                                                   See startup file startup_LPC17xx.s for SysTick vector */
}
int main (void)  {
  uint32_t returnCode;
  returnCode = SysTick_Config(SystemCoreClock / 1000);      /* Configure SysTick to generate an interrupt every millisecond */
if (returnCode != 0)  {                                   /* Check return code for errors */
// Error Handling
  }
while(1);
}

I'm using STM32L.  Thanks a lot!!

~S

Outcomes