I have a breakpoint set on the last line of the program below: t = getTicks();
If SYSTEM_TICKS_PER_SECOND is set to 100,000 the breakpoint triggers.
If I set it to 1,000,000 the breakpoint does not trigger.
This sounds like all of the processor's time is spent in the ISR or it is not clearing. Systick is said to be self-clearing and I do not think that is the case as on the scope the blips are 1 microsecond apart. Maybe systick uses more processing power/time than I thought. I chose systick because of its high priority, -1, but maybe an external timer would be less burden on the ARM core.
The clock set to 80 MHz so I would think it would have time to do other things. Please set me straight.
.
#include <stdint.h> #include <stdbool.h> #include "inc/hw_memmap.h" #include "driverlib/gpio.h" #include "driverlib/rom_map.h" #include "driverlib/sysctl.h" #include "systick.h" #define SYSTEM_TICKS_PER_SECOND 1000000UL static uint64_t ticks; static bool sytickConfigured = false; void systickSetup(void) { SysTickPeriodSet(SysCtlClockGet() / SYSTEM_TICKS_PER_SECOND); SysTickIntRegister(systickISR); SysTickEnable(); SysTickIntEnable(); sytickConfigured = true; } uint64_t getTicks() { volatile uint64_t pete; volatile uint64_t repeat; //Deal with ISR updates during non-atomic read pete = ticks; repeat = ticks; while ( pete != repeat ) { pete = repeat; //This should be just a register move, fairly efficient. repeat = ticks; } return pete; } static void systickISR() { volatile static bool toggle = 1; ticks++; // Microseconds since power up. //Create 1 MHz blips on scope //jvh GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); //Blue GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); //Tickle scheduler... } int main(void) { volatile uint64_t t = 0; // Set clock to 80 MHz - my eval board is 16 MHz instead of 20 MHz MAP_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); //jvh - change freq SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2); systickSetup(); while (1) { SysCtlDelay(1000); //100000 cycles is between 4500 and 15000 uSec, depending on load. t = getTicks(); } }