Skip to content

Instantly share code, notes, and snippets.

@MayaPosch
Created October 29, 2020 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MayaPosch/62653ebd97f8c0e84d9c225844445cf4 to your computer and use it in GitHub Desktop.
Save MayaPosch/62653ebd97f8c0e84d9c225844445cf4 to your computer and use it in GitHub Desktop.
STM32 Timer SysTick init
Timer::Timer() {
// Set reload register to generate an interrupt every millisecond.
SysTick->LOAD = (uint32_t)((SystemCoreClock / 1000) - 1);
// Reset the SysTick counter value.
SysTick->VAL = 0UL;
// Set SysTick source and IRQ.
SysTick->CTRL = (SysTick_CTRL_CLKSOURCE_Msk | SysTick_CTRL_TICKINT_Msk);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment