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.

Can I not use HWI when using interrupts?

Other Parts Discussed in Thread: SYSBIOS


Version:
RTOS for TM4C 2_16_01_14


Hi everyone,

So I've been trying to use TI RTOS. I have multiple questions but I will do some more digging before I ask them all. The one question I want to make now is related to interrupts.

Can I set up a interrupt like when I did without RTOS? I had some code that would setup the interrupt handler and whatnot and tried to use it. I had to add .vtable into the linker.cmd, although with a bit cheating, because I just set it anywhere in the RAM.
Do I have to always use the HWI, so I have to adapt my whole code to use it? I prefer to have everything in run time because of the files working like a API, instead of having to set everything up in the .cfg (it's seems that's an option, correct me if I am wrong).

The only example I found was for a GPIO interrupt, using a Tm4C RTOS Driver (not tivaware). Are there any more examples in how to setup a ISR with TI RTOS?



  • Hello, i'm not an expert, hopefully this is accurate enough to help.

    You can declare HWIs (hardware interrupts) two ways using TI-RTOS:

    1) Statically through the .cfg file which will be set up before main() executes (Recommended)

    2) Dynamically at runtime by importing the TI-RTOS HWI library as described in the "TI-RTOS Kernel User's Guide" Page. 167 or Section 8.2.1 with the following code snippet copied from there (Recommended)

    #include <ti/sysbios/hal/Hwi.h>
    #include <xdc/runtime/Error.h>
    #include <xdc/runtime/System.h>
    
    Hwi_Handle myHwi;
    Error_Block eb;
    Error_init(&eb);
    
    myHwi = Hwi_create(5, myIsr, NULL, &eb);
    
    if (myHwi == NULL) {
       System_abort("Hwi create failed");
    }

    If I understand you correctly, you would prefer to do it manually by configuring the interrupt table, ISR, and setting the interrupt source, etc. This is possible, but to my knowledge not the best practice when using TI-RTOS since it could create conflicts as you are bypassing the OS.

    If you insist on the other hand, I believe you can do this manually using the configuration numbers directly from the datasheet / family manual and setting the appropriate registers as previously done. The better way would be to use the lower level TI-RTOS DriverLib or Device Specific "ware" libraries (IE: CC26xxWare) which set the internal Mux's to peripherals, etc for you. But as mentioned, its my understanding that these libraries are generally used by higher level driver libraries and inappropriate use can break things. Furthermore, I believe using the TI-RTOS HWIs (dynamic or static) will be the best choice.

    As mentioned, i'm not an expert on this and I may be incorrect on a few of these points. Feel free to correct me if i'm mistaken.

  • Hi DMor, and thanks for your time

    I have successfully used both options to set up a HWI.

    I have also used a interrupt like I would without a RTOS - but I had to cheat a bit on the linker and add a section called .vtable


    This creates me some confusion also because I used FreeRTOS before with other MCU and I didn't have any diference when using interrupts in the specific port I used.

    I'm still trying to understand the mechanics of the HWI and the implications of using it or not. I'm gonna keep searching for that info and if any TI RTOS pros have the answer, please share it :)
  • Hi Luis,

    Dmor's answer is correct for creating Hwi's in which you're using the Kernel's scheduler to process the interrupt. However, if you'd like to bypass the scheduler entirely we offer "zero" latency interrupts in which you create a Hwi with a priority of 0, but keep in mind that certain BIOS API's cannot be called from within the ISR.

    Please see the following Wiki for information on the restricted API's and how to create this Hwi.

    processors.wiki.ti.com/.../BIOS_for_Stellaris_Devices

    Best,
    Alexander
  • Yes thank you very much both of you.

    I might have some doubts related to HWI though.

    When you exit out of the HWI ISR, it will call the scheduler and run the highest priority ready task right?
    Swi_post(), Semaphore_post(), Event_post() will only set a flag for a software interrupt/ unlock a semaphore (if locked) and then when the ISR ends, the scheduler will still run, correct?

    It does not necessarily force the "posted" task/swi to run (well SWI should run right away due to the high priority.
  • I believe you are correct, but the easiest way to verify this is to use the RTOS Analyser > Execution Graph which will show you precisely the execution of your system. You'll need to "use" and enable LoggingSetup in the .cfg file and select which process to monitor by check-marking hwi, swi, task, etc in the configuration page. At the bottom of the same page, make sure to allocate enough memory in Logger Buffer Size > Buffer Sizes (MAUs) or some the data may be lost.

    I believe you also have to go to the .cfg BIOS config page by going to: TI-RTOS > Products > SYSBIOS > BIOS > Runtime (top of page) and enable "Asserts" and "Logs". Debug the application and before pressing the start / play button, go to Tools > RTOS Analyser > Execution Analysis. This graph will show you precisely what happens after your HWI, SWI, or Task.