Using the code below, the clock is set for 80 MHz. Here are some results for the interrrupt interval for various values in MAP_TimerLoadSet(). Have I setup something wrong?
Load Measured Expected
320 249.25 KHz 250 KHz
160 497 KHz 500 KHz
80 823 KHz 1 MHz
40 821 KHz 2 MHz
#include <stdint.h> #include <stdbool.h> #include "inc/hw_ints.h" #include "inc/hw_memmap.h" #include "inc/hw_types.h" #include "driverlib/debug.h" #include "driverlib/fpu.h" #include "driverlib/gpio.h" #include "driverlib/interrupt.h" #include "driverlib/pin_map.h" #include "driverlib/rom.h" #include "driverlib/rom_map.h" #include "driverlib/sysctl.h" #include "driverlib/timer.h" #include "driverlib/uart.h" #include "utils/uartstdio.h" #define SYSTEM_TICKS_PER_SECOND 1000000UL volatile static uint64_t ticks; void Timer0IntHandler(); uint64_t getTicks(); void Timer0IntHandler() { static bool toggle = 1; TimerIntClear(TIMER0_BASE, TIMER_TIMA_TIMEOUT); ticks++; // Microseconds since power up. GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); //Blue GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); toggle = !toggle; //Tickle scheduler... } int main(void) { volatile uint32_t loops = 0; volatile uint64_t t; MAP_SysCtlClockSet(SYSCTL_SYSDIV_2_5 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ); // LED debugging setup MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); MAP_GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_2 | GPIO_PIN_3); //Timer 0 setup. MAP_SysCtlPeripheralEnable(SYSCTL_PERIPH_TIMER0); MAP_IntMasterEnable(); MAP_TimerConfigure(TIMER0_BASE, TIMER_CFG_PERIODIC); MAP_TimerLoadSet(TIMER0_BASE, TIMER_A, 40UL); //(SysCtlClockGet() / SYSTEM_TICKS_PER_SECOND)); MAP_IntEnable(INT_TIMER0A); MAP_TimerIntEnable(TIMER0_BASE, TIMER_TIMA_TIMEOUT); MAP_TimerEnable(TIMER0_BASE, TIMER_A); while(1) { } }