So I used an Atmel Start generated project, and I am using the following code to configure and enable systick:
// Configure SysTick to trigger every millisecond using the CPU Clock
SysTick->CTRL = 0; // Disable the SysTick Module
SysTick->LOAD = 119999UL; // Set the Reload Register for 1mS interrupts
NVIC_SetPriority(SysTick_IRQn, 3); // Set the interrupt priority to least urgency
SysTick->VAL = 0; // Clear the Current Value register
SysTick->CTRL = 0x00000007; // Enable SysTick, Enable SysTick Exceptions, Use CPU Clock
NVIC_EnableIRQ(SysTick_IRQn); // Enable the SysTick Interrupt (Global)
When I run this code, my delay_ms function is off. 1 ms = roughly 4 ms for some reason.
I think this is because I added a delay driver in the Atmel Start generator, but added the SysTick stuff manually and they might be colliding somehow? Is there a way to turn systick on in Atmel Start that doesn't interfere with the delay driver?