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.

EK-TM4C1294XL: tm4c1294ncpdt

Part Number: EK-TM4C1294XL

hello, 

   in reading the response to this question i see you state the problem may be registering the int

does that mean you cant use GPIOIntRegisterPin(GPIO_PORTP_BASE, GPIO_PIN_1, &UserButton2ISR); 

to dynamically register the interrupt for that pin?

I find myself in need of doing just that. upon in terrupt on P1 part of the ISR is to register a new handler for any ensuing interrupts on P1

thanks

 

  • Hi Patrick,

      Yes, you can use GPIOIntRegisterPin for the specified port pin or GPIOIntRegister for the specified port. GPIOIntRegister/GPIOIntRegisterPin  will eventually call IntRegister to move the vector table from flash to SRAM and plug the ISR accordingly. 

    //*****************************************************************************
    //
    //! Registers an interrupt handler for an individual pin of a GPIO port.
    //!
    //! \param ui32Port is the base address of the GPIO port.
    //! \param ui32Pin is the pin whose interrupt is to be registered.
    //! \param pfnIntHandler is a pointer to the GPIO port interrupt handling
    //! function.
    //!
    //! This function ensures that the interrupt handler specified by
    //! \e pfnIntHandler is called when an interrupt is detected from the selected
    //! pin of a GPIO port. This function also enables the corresponding GPIO pin
    //! interrupt in the interrupt controller.
    //!
    //! \sa IntRegister() for important information about registering interrupt
    //! handlers.
    //!
    //! \return None.
    //
    //*****************************************************************************
    void
    GPIOIntRegisterPin(uint32_t ui32Port, uint32_t ui32Pin,
    void (*pfnIntHandler)(void))
    {
    uint32_t ui32Int;

    //
    // Check the arguments.
    //
    ASSERT((ui32Port == GPIO_PORTP_BASE) || (ui32Port == GPIO_PORTQ_BASE));
    ASSERT((ui32Pin > 0) && (ui32Pin < 8));
    ASSERT(pfnIntHandler != 0);

    //
    // Get the interrupt number associated with the specified GPIO.
    //
    ui32Int = _GPIOIntNumberGet(ui32Port);

    //
    // Register the interrupt handler.
    //
    IntRegister((ui32Int + ui32Pin), pfnIntHandler);

    //
    // Enable the GPIO pin interrupt.
    //
    IntEnable(ui32Int + ui32Pin);
    }

    void
    IntRegister(uint32_t ui32Interrupt, void (*pfnHandler)(void))
    {
    uint32_t ui32Idx, ui32Value;

    //
    // Check the arguments.
    //
    ASSERT(ui32Interrupt < NUM_INTERRUPTS);

    //
    // Make sure that the RAM vector table is correctly aligned.
    //
    ASSERT(((uint32_t)g_pfnRAMVectors & 0x000003ff) == 0);

    //
    // See if the RAM vector table has been initialized.
    //
    if(HWREG(NVIC_VTABLE) != (uint32_t)g_pfnRAMVectors)
    {
    //
    // Copy the vector table from the beginning of FLASH to the RAM vector
    // table.
    //
    ui32Value = HWREG(NVIC_VTABLE);
    for(ui32Idx = 0; ui32Idx < NUM_INTERRUPTS; ui32Idx++)
    {
    g_pfnRAMVectors[ui32Idx] = (void (*)(void))HWREG((ui32Idx * 4) +
    ui32Value);
    }

    //
    // Point the NVIC at the RAM vector table.
    //
    HWREG(NVIC_VTABLE) = (uint32_t)g_pfnRAMVectors;
    }

    //
    // Save the interrupt handler.
    //
    g_pfnRAMVectors[ui32Interrupt] = pfnHandler;
    }

  • thanks i got it sorted. 

    important note: when you designate the pin# in the call to the function you must use the actual pin number. Can not use the GPIO_PIN_x defines

  • Hi Patrick,

      You are right. It needs to be a actual number like '1' instead of GPIO_PIN_1 which is 0x00000002.