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.

How to trigger interrupt in RTOS

Other Parts Discussed in Thread: CC2650

Hi, I am new to RTOS, I use the config file to define an ISR which related to a input button of the launch pad. but not like the regular interrupt define and init, this only ask for the ISR name and Interrupt number, is that all? cause when I using the board without a RTOS, it require to init the PIN and digital input and the trigger event is rising edge, where to set these parameters?

Thanks

Shan

  • Hi Shan,

    I would recommend looking at our GPIO Interrupt example for the board that you're using. In order to set up an ISR. We have a separate Board.c(EX. CC2650_LAUNCHXL.c), that sets up the trigger event and whether a pin is an input or output. In the gpiointerrupt.c file, the lines:

    /* install Button callback */
    GPIO_setCallback(Board_BUTTON1, gpioButtonFxn1);
    GPIO_enableInt(Board_BUTTON1);


    Register the function gpioButtonFxn1 as the function to be run when the interrupt on that pin occurs, in addition to enabling the interrupt. The symbol

    Board_BUTTON1 is an alias to a switch on the CC2650 defined in the Board.h file where it maps to an entry in the enum within the CC2650_LAUNCHXL.h file:

    So in order to set up a new pin, you'll have to add it to your board specific .c and .h file with the desired settings, and register the callback and enable the interrupt in your c code. The GPIO driver takes care of creating the Hwi object for you.

    For more information on using the GPIO driver, you may look at your TIRTOS' doxygen page:

    Ex) C:/ti/tirtos_cc32xx_2_16_00_05_eng/products/tidrivers_cc32xx_2_16_00_05_eng/docs/doxygen/html/index.html

    Note: I used the CC26XX as an example, but a similar approach applies to all supported boards

    Best,

    Alexander

  • GPIO_PinConfig gpioPinConfigs[] = {
        /* Input pins */
        /* EK_TM4C129EXL_USR_SW1 */
        GPIOTiva_PJ_0 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
        /* EK_TM4C129EXL_USR_SW2 */
        GPIOTiva_PJ_1 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
    
        /* Output pins */
        /* EK_TM4C129EXL_USR_D1 */
        GPIOTiva_PN_1 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
        /* EK_TM4C129EXL_USR_D2 */
        GPIOTiva_PN_0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
    };
    
    /*
     * Array of callback function pointers
     * NOTE: The order of the pin configurations must coincide with what was
     *       defined in EK_TM4C129EXL.h
     * NOTE: Pins not used for interrupts can be omitted from callbacks array to
     *       reduce memory usage (if placed at end of gpioPinConfigs array).
     */
    GPIO_CallbackFxn gpioCallbackFunctions[] = {
        /*NULL, */ EK_TM4C129EXL_USR_SW1,
       /* NULL */   EK_TM4C129EXL_USR_SW2
    };
    

    Hi, Alex,thanks for your reply, I am a little confused that "The GPIO driver takes care of creating the Hwi object for you."

    I see this is a class-like file, there is c and h  file, where the class file was used in the main function?

    for the question about the GPIO driver create the Hwi for me, does that mean the hwi was create dynamically?

    Thanks

    Shan

    For the TM4C129 board I found the code below.

  • I am trying to create the Hwi manually through the cfg scheduling, set up the ISR function name, the Interrupt number, if I want to keep in this way and set up the trigger method, where should I go?

    Shan
  • I found that the answer for the question 1:

     */
    int main(void)
    {
        /* Call board init functions */
        Board_initGeneral();
        Board_initGPIO();
        Board_initUART();
    
        /* Turn on user LED */
        GPIO_write(Board_LED0, Board_LED_ON);
    
        System_printf("Starting the GPIO Interrupt example\nSystem provider is set"
                      " to SysMin. Halt the target to view any SysMin contents in"
                      " ROV.\n");
        /* SysMin will only print to the console when you call flush or exit */
        System_flush();
    
        /* install Button callback */
        GPIO_setCallback(Board_BUTTON0, gpioButtonFxn0);
    
        /* Enable interrupts */
        GPIO_enableInt(Board_BUTTON0);
    
        /*
         *  If more than one input pin is available for your device, interrupts
         *  will be enabled on Board_BUTTON1.
         */
        if (Board_BUTTON0 != Board_BUTTON1) {
            /* install Button callback */
            GPIO_setCallback(Board_BUTTON1, gpioButtonFxn1);
            GPIO_enableInt(Board_BUTTON1);
        }
    
        /* Start BIOS */
        BIOS_start();
    
        return (0);
    }
    

  • Hi Shan,

    Yes the driver does create the Hwi object dynamically. This is because the ports on devices map to single interrupt numbers, so that it takes care of checking which pin was triggered.  You may see the code to create the Hwi in the GPIO driver itself:

    As such, you do not need to add a separate Hwi to your .cfg file.

    The source code can be found within your TIRTOS installation.

    Ex) C:\ti\tirtos_tivac_2_16_00_03_eng\products\tidrivers_tivac_2_16_00_03_eng\packages\ti\drivers\gpio

    Best,

    Alexander