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.

Question about how the interrupts are handled when running the TI/RTOS on the Tiva CPU.

Other Parts Discussed in Thread: SYSBIOS

My goal is to convert a USB bulk example from Stellarisware to the new Tiva CPU running TI RTOS.   We have a product that uses a 9D96 Stellaris CPU that we need to migrate to a Tiva CPU due to obsolesce of the Stellaris 9D96 CPU.  I understood how the Stellaris CPU worked and how to add and manage IRQ’s but I do not understand the IRQ’s are managed with the Tiva CPU’s when running the TI RTOS.

With the Stellarisware, there was a file in every example project Startup_ccs.c that had all the IRQ vectors listed.  The unused vectors were all mapped to the function IntDefaultHandler() and to add a IRQ handler, I would create a function a plug it in the right location in the vector table and everything would work.

I have been looking at Tiva Examples using CCS 6.0.1 and a Tiva C eval board TM4C1294.  One example I found was the example gpiointerrupt_TivaTM4C1294NCPDT that I can load and run to understand the interrupts.   In the example gpiointerrupt_TivaTM4C1294NCPDT, I was looking at how the IRQ’s are configured.  I would have thought that IRQ handlers are added through the GUI by opening the file gpiointerrupt.cfg and going to the Hwi button and adding an instance of a hardware interrupt.   The example gpiointerrupt_TivaTM4C1294NCPDT does not add the IRQ via the GUI as I thought it would be.  I see all the RTOS examples have files EK_TM4C1294XL.c and EK_TM4C1294XL.h included but I don’t see the vectors or how to add and manage them.

Can someone explain the recommended way the interrupts are managed with the TI RTOS for the Tiva C?

Thanks,

Doug

  • Doug,

    In those example you will find a Hwi_Struct object and then you will find something like the following in the init function:

    Hwi_Params_init(&hwiParams);
    Hwi_construct(&(hwiStruct), INT_UDMAERR, EK_TM4C123GXL_errorDMAHwi,
    &hwiParams, &eb);

    This is the code that is plugging the interrupt vector at runtime.

    Hwi_construct is a way to plug an interrupt vector at runtime without needing to do dynamic memory allocation.

    Hwi_create can also be used but it does dynamic memory allocation.

    You can also plug a Hwi via the GUI if you choose to do it that way.

    For TI-RTOS examples, it makes since for the drivers to do this at runtime as they are needed.

    Judah

  • Doug,

    Just wanted to also mention that you can see the list of interrupt vectors plugged using the ROV (RTSC Object Viewer) available in CCS.

    Judah

  • Judah,

    I have been looking at your advice and the ROV was helpful as was the first post on how the provided examples work.

    Right now, I am just working understanding how I should implement the hardware interrupts.  I have experience with multiple operating systems and doing this kind of thing so the idea is not new, just the specific implementation in this case.  I see some differences between the provided examples and the documentation that I would like to better understand.  I broke this into three sections below to better separate things.  The three sections are what I see in the documentation  or PDF’s, what I see in the provided examples that I can compile and run provided by TI and last section is the questions.

    Documentation:

    I am using the document BIOS_User_GUIDE.pdf SPRUEX3N March 2014 as a reference for the interrupts.   In looking at sections 3.3 and section 7.2, I see the following functions being used.

    Hwi_Parmas_init() and Hwi_Create() in section 7.2.3

    When I look at the documentation, it makes sense what they are doing.  The function Hwi_Parmas_init()  looks like it initializes the structure and the function Hwi_Create() looks like it can modify an entry in the structure that Hwi_Parmas_init()  initializes.   I looks like that to plug in an interrupt, call the function Hwi_Parmas_init() then use  Hwi_Create() to plug in the new interrupt  I did not find where the functions Hwi_Parmas_init() and Hwi_Create()  are documented to describe the parameters and return value of the functions listed above but that is what it looks like it is doing. 

     

    Provided examples.

    In your first reply, you listed the following functions to use base on the examples provided.  I have been referencing example project gpiointerrupts_TivaTM4C1294NCPDT.

    Hwi_Params_init(&hwiParams);
    Hwi_construct(&(hwiStruct), INT_UDMAERR, EK_TM4C123GXL_errorDMAHwi,
    &hwiParams, &eb);

    I have not found the function Hwi_construct() documented.

    When I look at the sample application gpiointerrupts_TivaTM4C1294NCPDT, I see in the source file EK_TM4C1294XL.c where the function Hwi_construct() is used. In looking over the example, I also see the following code:

    /* Memory for the GPIO module to construct a Hwi */

    Hwi_Struct callbackPortJHwi;

     

    const GPIO_Callbacks EK_TM4C1294XL_gpioPortJCallbacks = {

        GPIO_PORTJ_BASE, INT_GPIOJ, &callbackPortJHwi,

        {gpioButtonFxn0, gpioButtonFxn1, NULL, NULL, NULL, NULL, NULL, NULL}

    };

     

    I also see the following.

    /* Hwi_Struct used in the usbBusFault Hwi_construct call */

    static Hwi_Struct usbBusFaultHwiStruct;

            GPIOPadConfigSet(GPIO_PORTQ_BASE, GPIO_PIN_4,

                             GPIO_STRENGTH_2MA, GPIO_PIN_TYPE_STD_WPU);

            GPIOIntTypeSet(GPIO_PORTQ_BASE, GPIO_PIN_4, GPIO_FALLING_EDGE);

            GPIOIntClear(GPIO_PORTQ_BASE, GPIO_PIN_4);

     

            /* Create a Hwi for PQ4 pin. */

            Error_init(&eb);

            Hwi_Params_init(&hwiParams);

            Hwi_construct(&(usbBusFaultHwiStruct), INT_GPIOQ4,

                          EK_TM4C1294XL_usbBusFaultHwi, &hwiParams, &eb);

            if (Error_check(&eb)) {

                System_abort("Couldn't construct USB bus fault hwi");

            }

     

     

    Questions:

    It looks like the provided example examples implement the interrupts differently than the documentation shows.    

    Question 1 Where do I find the functions documented?

    Hwi_Parmas_init()

    Hwi_Create()

    Hwi_construct()

    Question 2  For the CPU I am using should I use

    Hwi_Parmas_init()  and Hwi_Create()

    or

    Hwi_Parmas_init() and Hwi_construct()

    Maybe I should ask what are the difference between using Hwi_Create() and Hwi_construct()?

    Doug

     

  • Doug,

    The documentation for those functions can be found in the 'cdoc' under <SYSBIOS>/docs/cdoc.  It contains all SYSBIOS API's for each module.

    I think I tried to explain the difference between create() vs construct() before but I'll try it here again.    The main difference between the two is create() does dynamic allocation from the heap at runtime and construct() does not.  For the TIRTOS drivers, it makes sense to call construct() because they want to avoid any runtime dynamic memory allocation.

    If you're doing this from the application, I would recommend doing create().  If you're doing this from a driver or some third party software, it might make sense to do it as construct() to avoid memory allocation.

    Judah