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.

Meaning of HOOKS in SWIs and HWIs

Other Parts Discussed in Thread: SYSBIOS

Hi,

I'm studying the threading modules of Sys/Bios to apply them on C6678.

I can't indertand whats the role of Hook functions in SWis and HWis.

1. I can creat a static HWi of SWi without calling Hook functions ?

2. Can someone give me a very simple example of creating a SWi and HWi and execute a fucntion when the interruption is posted ?

Sincerly,

Youssef

  • 1) You do not need to define Hooks to configure an interrupt handler. The Hooks are primarily meant to be used for instrumenting existing Hwis or Swis.

    2) Chapter 3.3.1 of the SYS/BIOS User's guide shows how to configure a Hwi object (ie bind an ISR function to an interrupt). Examples of both static and dynamic Hwi creation are provided. At runtime, the following example code can be used to bind the C function 'myIsr' to interrupt #10 and have the value '5' passed to it:

    #include <ti/sysbios/hal/Hwi.h>

    Hwi_Handle hwi0;

    main()
    {
       Hwi_Params hwiParams;
       Error_Block eb;

       Error_init(&eb);
       Hwi_Params_init(&hwiParams);

       hwiParams.arg = 5;
       hwi0 = Hwi_create(10, '&myIsr', &hwiParams, &eb);

       if (hwi0 == NULL) {
           System_abort("Hwi create failed");
       }

        BIOS_start();
    }

    Void myIsr(UArg arg)
    {
    }
    Alan
  • Thanks Alan,

    Just one more detail,

    When the Hwi is triggered myIsr fucntion will be executed immediately or at the end of main execution because when i tried this example :

    #include <xdc/runtime/Error.h>
    #include <ti/sysbios/hal/Hwi.h>
    #include <ti/sysbios/BIOS.h>
    #include <xdc/runtime/System.h>
    #include <ti/sysbios/hal/Timer.h>


    Hwi_Handle myHwi;
    int somme;

    Void myIsr(UArg arg)
    {
    System_printf("myIsr %d\n",arg);
    System_exit(0);
    }

    Int main(Int argc, char* argv[])
    {
    Hwi_Params hwiParams;
    Error_Block eb;

    Hwi_Params_init(&hwiParams);
    Error_init(&eb);

    // set the argument you want passed to your ISR function
    hwiParams.arg = 2000;

    // set the event id of the peripheral assigned to this interrupt
    hwiParams.eventId = 10;

    // don't allow this interrupt to nest itself
    hwiParams.maskSetting = Hwi_MaskingOption_SELF;

    System_printf("Before creating Hwi\n");
    myHwi = Hwi_create(5, myIsr, &hwiParams, &eb);

    if (Error_check(&eb)) {
    // handle the error
    }

    System_printf("Before posting Hwi\n");
    Hwi_post(5);
    System_printf("After posting Hwi\n");

    BIOS_start();
    return 0;
    }

    I got this result :

    Before creating Hwi
    Before posting Hwi
    After posting Hwi
    myIsr 2000

    But normally i excpect this result :

    Before creating Hwi
    Before posting Hwi

    myIsr 2000

    After posting Hwi

    Sincerly 

    Youssef

  • Global interrupts are disabled in main() so that they can be safely enabled within BIOS_Start().

    If you run your test sequence from within a Task thread you'll get the expected results.

    Alan