I am just about to start using timers for my project and I got stuck immediately with the startup sequence. Timer0 is used to check for incoming data over a TCP link, timer1 is going to be used to control the timing of a AFE.
If anyone can point me directly to the first few places on ti.com or know some code examples that I should look at I would be very grateful! I am using the Tiva C EK-TM4C123GXL with the CC3000.
In the ccs.c filer:
// External declarations for the interrupt handlers used by the application.
extern void Timer0IntHandler( void );
extern void Timer1IntHandler( void );
void (* const g_pfnVectors[])( void) = {( void (*)( void ))((unsigned long)&__STACK_TOP),
Timer0IntHandler, // Timer 0 subtimer A
Timer1IntHandler, // Timer 1 subtimer A
The code I am using in my main.c:
void HWinit( void )
{
FPULazyStackingEnable (); //Allows floating-point instructions.
SysTickPeriodSet (SysCtlClockGet () / SYSTICK_PER_SEC); //
SysTickIntEnable ();//
SysTickEnable ();//
// Initializes the CPU usage measurement module with the usage of timer 2.
CPUUsageInit (SysCtlClockGet (), SYSTICK_PER_SEC, 2); //
// MCU set @ 50Mhz, NOT stable @ 80Mhz!
SysCtlClockSet(SYSCTL_SYSDIV_4 | SYSCTL_USE_PLL | SYSCTL_OSC_MAIN | SYSCTL_XTAL_16MHZ);
//-------------- Enable peripherals ---------------------------------------------------------
SysCtlPeripheralClockGating (true); // Enable peripherals to operate when CPU is in sleep
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI0); // Enable SSI0 peripheral AFE
SysCtlPeripheralEnable(SYSCTL_PERIPH_SSI1); // Enable SSI1 peripheral uDMA
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); // Enables port PA2 and PA4 for SSI0
SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOC); //
SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOD); //
SysCtlPeripheralEnable (SYSCTL_PERIPH_GPIOF); //
SysCtlPeripheralEnable (SYSCTL_PERIPH_UART0); // Virtual port
SysCtlPeripheralEnable (SYSCTL_PERIPH_TIMER0); // Acquisition frequency
//-------------- Enable peripherals Sleep Mode ----------------------------------------------------
SysCtlPeripheralSleepEnable (SYSCTL_PERIPH_SSI0); // Enable SSI0 peripheral Sleep for AFE
GPIOPinTypeGPIOOutput (GPIO_PORTF_BASE, GPIO_PIN_2); //Enable pin for LED PF2
//-------------- AFE SPI (SSI0) -------------------------------------------------------------------
GPIOPinConfigure (GPIO_PA2_SSI0CLK);
GPIOPinConfigure (GPIO_PA4_SSI0RX);
// Configure the GPIO settings for the SSI pins. This function also gives control of these pins to the SSI hardware.
GPIOPinTypeSSI (GPIO_PORTA_BASE, GPIO_PIN_4 | GPIO_PIN_2);
// Configure and enable the SSI port for SPI master mode.
SSIConfigSetExpClk (SSI0_BASE, SysCtlClockGet(), SSI_FRF_MOTO_MODE_0, SSI_MODE_MASTER, 1000000, 16);
// Enable SSI0 interrupt
IntEnable (INT_SSI0);
// SSI0 is configured to use uDMA
SSIDMAEnable (SSI0_BASE, SSI_DMA_TX | SSI_DMA_RX);
// Enable the SSI0 module.
SSIEnable (SSI0_BASE);
unsigned long ulDataRx;
while (SSIDataGetNonBlocking (SSI0_BASE, &ulDataRx))
{
}
// -------------- INIT TIMERS -------------------------------------------------------------------
// Enable processor interrupts.
IntMasterEnable ();
// Configure 32-bit periodic timers.
TimerConfigure (TIMER0_BASE, TIMER_CFG_PERIODIC);
TimerConfigure (TIMER1_BASE, TIMER_CFG_PERIODIC); The system crashes here!
TimerLoadSet (TIMER0_BASE, TIMER_A, SysCtlClockGet());
TimerLoadSet (TIMER1_BASE, TIMER_A, SysCtlClockGet ());
// Setup the interrupts for the timer timeouts.
IntEnable (INT_TIMER0A);
IntEnable (INT_TIMER1A);
TimerIntEnable (TIMER0_BASE, TIMER_TIMA_TIMEOUT);
TimerIntEnable (TIMER1_BASE, TIMER_TIMA_TIMEOUT);
}
When the system crashes it ends up in:
static void
FaultISR( void )
{
//
// Enter an infinite loop.
//
while (1)
{
}
}
And I can not see what I have done wrong in the startup sequence.