This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Example code with timers and interrupts

I am having a hard time finding any good sample code for using timers and interrupts with the Cortex M3 and the Keil compiler. For that matter, I can't even find any examples of simply how to use interrupts. Is there a good, easy example for interrupts and the M3 on the Keil site anywhere? I have looked and looked and found nothing.

I have tried writing a simple bit of code to enable a periodic timer and have an interrupt handler that simply clears the interrupt flag and returns. However, when I try to single step, the 2nd line (regardless of what the 2nd line is) always throws me into the "FaultISR". The comments say it's the code that gets called when the processor receives a fault interrupt.

My code is posted below. Can anyone help explain why this is faulting?

Thanks,
PeterM

#include "lm3s6965.h"

void TimerA0_Int_Handler(void){

 /* To clear the status flag when the timer interrupts,
                set bit "TnTOCINT" in TIMER0_ICR_R  */
        TIMER0_ICR_R |= TIMER_ICR_TATOCINT;
        return;
}

int main(void){

        // Setup timer 0's A timer for continuous run
        TIMER0_CFG_R = TIMER_CFG_16_BIT;        // 0x04 = 16 bit mode. GPTM Configuration Register (GPTMCFG)
        TIMER0_TAMR_R = TIMER_TAMR_TAMR_PERIOD; // Run in periodic (continuous) mode.    GPTM Timer Mode (GPTMTnMR)

        TIMER0_TAPR_R = 0; // Set the prescale value. GPTM Timern Prescale Register (GPTMTnPR)
        TIMER0_TAILR_R = 0x100; // Set start value for timer. GPTM Timer Interval Load Register (GPTMTnILR)

        TIMER0_IMR_R |= TIMER_IMR_TATOIM; // Set bit to enable interrupts for timer. GPTM Interrupt Mask Register (GPTMIMR)
        TIMER0_CTL_R |= TIMER_CTL_TAEN; // Set bit to enable timer.     GPTM Control Register (GPTMCTL)

 while(1){
 }
}