This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Interrupt handlers

I am new to the stellaris family and I am trying to find out how to set up my interrupts and write an ISR.  It might be right in front of me but I can't see how to do it.  I am looking at qs-scope and know that they use a system tick to start the data acq.  I can't find where you link the interrupt and the ISR.  Suggestions?

  • In the qs-scope example the interrupt vectors are declared and placed into the vector table in the startup file (startup_xxx.x depending on which dev tools you are using). Possibly this is the link you are missing?

    For example, here are the relevant lines from the startup_ccs.c file.   

    //*****************************************************************************
    //
    // External declarations for the interrupt handlers used by the application.
    //
    //*****************************************************************************
    extern void DataAcquisitionADCSeq0IntHandler(void);
    extern void DataAcquisitionAbortIntHandler(void);
    extern void ClassDPWMHandler(void);
    extern void SysTickIntHandler(void);
    extern void UARTStdioIntHandler(void);
    extern void USB0DualModeIntHandler(void);

    //*****************************************************************************
    //
    // The vector table.  Note that the proper constructs must be placed on this to
    // ensure that it ends up at physical address 0x0000.0000 or at the start of
    // the program if located at a start address other than 0.
    //
    //*****************************************************************************
    #pragma DATA_SECTION(g_pfnVectors, ".intvecs")
    void (* const g_pfnVectors[])(void) =
    {
        (void (*)(void))((unsigned long)&__STACK_TOP),
                                                // The initial stack pointer
        ResetISR,                               // The reset handler
        NmiSR,                                  // The NMI handler
        FaultISR,                               // The hard fault handler
        IntDefaultHandler,                      // The MPU fault handler
        IntDefaultHandler,                      // The bus fault handler
        IntDefaultHandler,                      // The usage fault handler
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        0,                                      // Reserved
        IntDefaultHandler,                      // SVCall handler
        IntDefaultHandler,                      // Debug monitor handler
        0,                                      // Reserved
        IntDefaultHandler,                      // The PendSV handler
        SysTickIntHandler,                      // The SysTick handler
        IntDefaultHandler,                      // GPIO Port A
        DataAcquisitionAbortIntHandler,         // GPIO Port B
        IntDefaultHandler,                      // GPIO Port C
        IntDefaultHandler,                      // GPIO Port D
        IntDefaultHandler,                      // GPIO Port E
        UARTStdioIntHandler,                    // UART0 Rx and Tx
        IntDefaultHandler,                      // UART1 Rx and Tx
        IntDefaultHandler,                      // SSI0 Rx and Tx
        IntDefaultHandler,                      // I2C0 Master and Slave
        IntDefaultHandler,                      // PWM Fault
        IntDefaultHandler,                      // PWM Generator 0
        ClassDPWMHandler,                       // PWM Generator 1
        IntDefaultHandler,                      // PWM Generator 2
        IntDefaultHandler,                      // Quadrature Encoder 0
        DataAcquisitionADCSeq0IntHandler,       // ADC Sequence 0
        IntDefaultHandler,                      // ADC Sequence 1
        IntDefaultHandler,                      // ADC Sequence 2
        IntDefaultHandler,                      // ADC Sequence 3
        IntDefaultHandler,                      // Watchdog timer
        IntDefaultHandler,                      // Timer 0 subtimer A
        IntDefaultHandler,                      // Timer 0 subtimer B
        IntDefaultHandler,                      // Timer 1 subtimer A
        IntDefaultHandler,                      // Timer 1 subtimer B
        IntDefaultHandler,                      // Timer 2 subtimer A
        IntDefaultHandler,                      // Timer 2 subtimer B
        IntDefaultHandler,                      // Analog Comparator 0
        IntDefaultHandler,                      // Analog Comparator 1
        IntDefaultHandler,                      // Analog Comparator 2
        IntDefaultHandler,                      // System Control (PLL, OSC, BO)
        IntDefaultHandler,                      // FLASH Control
        IntDefaultHandler,                      // GPIO Port F
        IntDefaultHandler,                      // GPIO Port G
        IntDefaultHandler,                      // GPIO Port H
        IntDefaultHandler,                      // UART2 Rx and Tx
        IntDefaultHandler,                      // SSI1 Rx and Tx
        IntDefaultHandler,                      // Timer 3 subtimer A
        IntDefaultHandler,                      // Timer 3 subtimer B
        IntDefaultHandler,                      // I2C1 Master and Slave
        IntDefaultHandler,                      // Quadrature Encoder 1
        IntDefaultHandler,                      // CAN0
        IntDefaultHandler,                      // CAN1
        IntDefaultHandler,                      // CAN2
        IntDefaultHandler,                      // Ethernet
        IntDefaultHandler,                      // Hibernate
        USB0DualModeIntHandler,                 // USB0
        IntDefaultHandler,                      // PWM Generator 3
        IntDefaultHandler,                      // uDMA Software Transfer
        IntDefaultHandler                       // uDMA Error
    };

     

     

  • ,OK, that is where they hid it.  I am using code composer studio.  What is the extension of the startup file that I should be using?

  • For CCS use startup_ccs.c.

  • I am also trying to add a int handler for my I2C routines and figured where I had to add it in the startup_ccs.c but when I compile & link, I get this error:

    <Linking>

    "../lm4f232h5qd.cmd", line 31: error #10099-D: placement fails for object

    ".intvecs", size 0x26c (page 0). Available ranges:

    FLASH size: 0x40000 unused: 0x3fcac max hole: 0x3fcac

    error #10010: errors encountered during linking; "Test Processor.out" not

    built

    I am using the dev kit with the LM4F232 part on it.

    I have also tried this line instead of adding the startup_ccs.c file and I get the same error.

    IntRegister(I2C0_MASTER_BASE,I2CIntHandler); // Hook the ISR

    Thoughts?

     

    Thanks, Jeff

  • I also use the dve kit LM4F232 and got the same problem to add the ISR in a SYS/BIOS project

    I add a startup_ccs.c and got the same error message as Jeff.

    How to add a interrupt in the SYS/BIOS project ?

    Thanks

  • Hey Steve I'm trying to understand interrupts better, and I'm going through a few youtube tutorials to get a better grasp. What I've understood so far is that we have to enable our interrupt, and also need to know the vector number for the interrupt. However it is still hard for me to understand what you just wrote. I know its a vector table but what does it mean?



    Also when there is an interrupt it appears to call a normal C function called an "interrupt handler" that I can define but how to do this exactly is confusing. For example, in AllaboutEE video at 2:06 I've found how enable the interrupt for General purpose timer A, through the IMR(interrupt mask register) and set register 0 to 1. Then I find the vector number from a header file. But he starts defining his ISR at the beginning of 5:30. How does the interrupt know to call his defined ISR? Can you shed some light because at this moment I'm at a loss of how to program interrupts.


    Here is one of the videos I went through(Quantum Leaps) -> www.youtube.com/watch
    Here is another (AllaboutEE)-> www.youtube.com/watch