Hi
I seem to be having trouble getting the General Purpose Timers to trigger an interrupt on timeout. I have configured the vector table, and the assembly correctly points to the Timer interrupt handler. Issue is, on timeout, the handler is never invoked, even though the Timer RIS register flags a timeout. My code is below:
#include "LM4F230H5QR.h"
#include <stdint.h>
int main() {
/* System Clock Setup in IAR Start Up */
// Clock Gating
SYSCTL->RCGC1 |= ((1U<<16)); // Enable Timer 0
SYSCTL->RCGC2 |= (1U<<5); // Enable clock to IO PORTF
SYSCTL->GPIOHBCTL |= (1U<<5); // Enable high speed periphreal bus for PORTF
// NVIC
NVIC_SetPriorityGrouping(0);
NVIC_EnableIRQ(TIMER0A_IRQn); // Enable TIMER0A Interrupt
NVIC_SetPriority(TIMER0A_IRQn,1); // Set TIMER0A Priority
// Initialize PORT F
GPIOF_AHB->DIR |= ((1U<<3)|(1U<<2)|(1U<<1)); // PIN 1,2,3 as output
GPIOF_AHB->DEN |= ((1U<<3)|(1U<<2)|(1U<<1)); // Enable PIN 1,2,3
// Timer config
TIMER0->CFG |= 0x0; // Set Timer0 to 32 bit
TIMER0->TAMR |= ((1U<<1)); // Set Timer 0 to periodic
TIMER0->IMR |= ((1U<<0)); // Enable timeout interrupt
TIMER0->TAILR |= 0xffff; // Timer 0 autoload value
// START TIMERS
TIMER0->CTL |= ((1U<<0)); // Enable Timer 0
while(1){
}
//return 0;
}
The weird thing is, the first time I compiled and loaded this code onto the Tiva C launch pad, the interrupt triggered. I then switched Timer0 A to 16 bit mode, and it stopped working. So, I immediately switched it back to 32 bit mode, and it is still not working... I have no clue why. Any tips would be greatly appreciated. I have found similar threads on the forum, but I am afraid they were of no use to me. I even tried adding delays to no avail, between each instruction to see if it was a setup/hold time violation.
Other Information:
Tool flow: IAR 7.20.1.7307
Optimizations: Off