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.

CC3220MODA: Learning How To Configure GPIO Pins, Getting Caugth in "while (Hwi_excHandlerFunc == NULL)"

Part Number: CC3220MODA
Other Parts Discussed in Thread: CC3220SF

I am working on a project that started out as the Network Terminal project.
We have some test points on our hardware which I would like to initilize as outpus so we can hang LEDs or logic analyser probes on them so that we can monitor status of code execution.
I was able to reuse the setup for the Launchpad LEDs for our LEDs but on different GPIO pins 10 and 11. After commenting out the conflicting setup for UART and PWM (in the board.h file)  I have them working.

Being careful to keep the enumerations on order and the same number, I tried to set up more GIPO as output by duplicating the setup which worked for the LED pins on GPIOCC32XX_GPIO_09, GPIOCC32XX_GPIO_10, and GPIOCC32XX_GPIO_11 in the file CC3220SF_LAUNCHXL.c and CC3220SF_LAUNCHXL.h, but for additional pins.  Here they are:

  /* ST365 R1 Test points */                                          //FLE 20190417
    GPIOCC32XX_GPIO_00 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,   // TP215
    GPIOCC32XX_GPIO_05 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,   // TP216
    GPIOCC32XX_GPIO_06 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,   // TP217
    GPIOCC32XX_GPIO_07 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,   // TP218
    GPIOCC32XX_GPIO_08 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,   // TP219

When I run the project, when the code gets to the write to make the first of the new pins high,  the code gets trapped in an interrupt handler.

 *  ======== Hwi_excHandler ========
 */
Void Hwi_excHandler(UInt *excStack, UInt lr)
{
    Hwi_module->excActive[0] = TRUE;

    /* spin here if no exception handler is plugged */
    while (Hwi_excHandlerFunc == NULL) {
    ;
    }

    Hwi_excHandlerFunc(excStack, lr);
}

I conclude that  I have not  correctly set up the pins or there is a conflicting setup for some other function on those pins but I do not know how to find such a conflict.

Had the comments in the code for  GPIOCC32XX_GPIO_10, and GPIOCC32XX_GPIO_11 not warned my about conflicts with UART and PWM pins I would have had no clue.  Perhaps I need to identify some similar conflicting changes for the new pins in the board.h file but do not see it.

I will provide fuller code examples in a following posts.

Suggestions for what I should do next?

  • Code from the CC3220SF_LAUNCHXL.c

    /*
     * Array of Pin configurations
     * NOTE: The order of the pin configurations must coincide with what was
     *       defined in CC3220SF_LAUNCHXL.h
     * NOTE: Pins not used for interrupts should be placed at the end of the
     *       array.  Callback entries can be omitted from callbacks array to
     *       reduce memory usage.
     */
    GPIO_PinConfig gpioPinConfigs[] = {
        /* input pins with callbacks */
    
        /* CC3220SF_LAUNCHXL_GPIO_SW2 */
    //    GPIOCC32XX_GPIO_13 | GPIO_CFG_INPUT | GPIO_CFG_IN_INT_RISING,
        /* CC3220SF_LAUNCHXL_GPIO_SW3 */
    //    GPIOCC32XX_GPIO_22 | GPIO_CFG_INPUT | GPIO_CFG_IN_INT_RISING,
        /* CC3220SF_LAUNCHXL_GPIO_SW2 */
        GPIOCC32XX_GPIO_13 | GPIO_DO_NOT_CONFIG,       //FLE 20190417 Do not initialize these pins which have no connection on ST365.
        /* CC3220SF_LAUNCHXL_GPIO_SW3 */
        GPIOCC32XX_GPIO_22 | GPIO_DO_NOT_CONFIG,       //FLE 20190417 Do not initialize these pins which have no connection on ST365.
    
    
        /* CC3220SF_LAUNCHXL_SPI_MASTER_READY */
        GPIOCC32XX_GPIO_28 | GPIO_DO_NOT_CONFIG,
        /* CC3220SF_LAUNCHXL_SPI_SLAVE_READY */
        GPIOCC32XX_GPIO_12 | GPIO_DO_NOT_CONFIG,
    
        /* output pins */
        /*
         *  CC3220SF_LAUNCHXL_GPIO_LED_D5 and CC3220SF_LAUNCHXL_GPIO_LED_D6 are shared with the
         *  I2C and PWM peripherals. In order for those examples to work, these
         *  LEDs are taken out of gpioPinConfig[]
         */
        /* CC3220SF_LAUNCHXL_GPIO_LED_D6 */
    //    GPIOCC32XX_GPIO_10 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW, // GAA 15Aug2018 U1TX
        /* CC3220SF_LAUNCHXL_GPIO_LED_D5 */
    //    GPIOCC32XX_GPIO_11 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW, // GAA 15Aug2018 U1RX
    
        /* CC3220SF_LAUNCHXL_GPIO_LED_D7 */
        GPIOCC32XX_GPIO_09 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,   // FLE 20190415 R1 LEDs  Launchpad blue, R1 WiFi XMT
        /* CC3220SF_LAUNCHXL_GPIO_LED_D9 */                           //FLE 20190412 Enabled.
        GPIOCC32XX_GPIO_10 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,   // FLE 20190415 R1 LEDs  Launchpad red, R1 WiFi RCV
        /* CC3220SF_LAUNCHXL_GPIO_LED_D8 */
        GPIOCC32XX_GPIO_11 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,   // FLE 20190415 R1 LEDs  Launchpad green, R1 P2P
        GPIOCC32XX_GPIO_15 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW, //  p.51 GAA 14Aug2018 RS485 TX Enable
    
        /* ST365 R1 Test points */                                          //FLE 20190417
        GPIOCC32XX_GPIO_00 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,   // TP215
        GPIOCC32XX_GPIO_05 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,   // TP216
        GPIOCC32XX_GPIO_06 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,   // TP217
        GPIOCC32XX_GPIO_07 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,   // TP218
        GPIOCC32XX_GPIO_08 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,   // TP219
    
        /* Sharp Display - GPIO configurations will be done in the Display files */
        GPIOCC32XX_GPIO_12 | GPIO_DO_NOT_CONFIG, /* SPI chip select */
        //GPIOCC32XX_GPIO_15 | GPIO_DO_NOT_CONFIG, /* LCD power control */    // FLE 20190415 Set same as reference code.
        GPIOCC32XX_GPIO_06 | GPIO_DO_NOT_CONFIG, /* LCD power control */      // FLE 20190415 Set same as reference code.
        GPIOCC32XX_GPIO_03 | GPIO_DO_NOT_CONFIG, /*LCD enable */
    
    };
    

  • Code from the CC3220SF_LAUNCHXL.h file.

    typedef enum CC3220SF_LAUNCHXL_GPIOName {
        CC3220SF_LAUNCHXL_GPIO_SW2 = 0,
        CC3220SF_LAUNCHXL_GPIO_SW3,
        CC3220SF_LAUNCHXL_SPI_MASTER_READY,
        CC3220SF_LAUNCHXL_SPI_SLAVE_READY,
        /*
         *  CC3220SF_LAUNCHXL_GPIO_LED_D5 and CC3220SF_LAUNCHXL_GPIO_LED_D6 are shared with the
         *  I2C and PWM peripherals. In order for those examples to work, these
         *  LEDs are  taken out of gpioPinCOnfig[]
         */
    //    CC3220SF_LAUNCHXL_GPIO_LED_D6,      // GAA 15Aug2018 being used for UART1
    //    CC3220SF_LAUNCHXL_GPIO_LED_D5,      // GAA 15Aug2018
    
        //CC3220SF_LAUNCHXL_GPIO_LED_D7,
        //FLE 20190412 LEDs for R1 PCB Enabled.
        CC3220SF_LAUNCHXL_GPIO_LED_D10,
        CC3220SF_LAUNCHXL_GPIO_LED_D9,                         //FLE 20190412 LED for R1 PCB Enabled.
        CC3220SF_LAUNCHXL_GPIO_LED_D8,
    
        CC3220SF_LAUNCHXL_RS485_TX_EN,      // GAA 14Aug2018
    
        CC3220SF_LAUNCHXL_GPIO_TP215,                         //FLE 20190417 ST365 R1 Test points
        CC3220SF_LAUNCHXL_GPIO_TP216,
        CC3220SF_LAUNCHXL_GPIO_TP217,
        CC3220SF_LAUNCHXL_GPIO_TP218,
        CC3220SF_LAUNCHXL_GPIO_TP219,
    
        /* Sharp 96x96 LCD Pins */
        CC3220SF_LAUNCHXL_LCD_CS,
        CC3220SF_LAUNCHXL_LCD_POWER,
        CC3220SF_LAUNCHXL_LCD_ENABLE,
    
    
        CC3220SF_LAUNCHXL_GPIOCOUNT,
    } CC3220SF_LAUNCHXL_GPIOName;

  • Code from main that sets the LED pins fine but when the code tries to set the first of the test points on line 24, (GPIO_write(CC3220SF_LAUNCHXL_GPIO_TP215,1); //Set TP215 high) it gets caught in the ISR trap.

    /*
     *  ======== main ==============================================================
     */
    int main(void)
    {
        pthread_t           thread;
        pthread_t           RS485thread;            // GAA 04May2018
        pthread_attr_t      pAttrs;
        struct sched_param  priParam;
        int                 retc;
        int                 detachState;
    
        /* Call board init functions */
        Board_initGeneral();
        //Let's make LEDs drive high (ST365 off)          //FLE 20190412
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_LED_D8,1);  //Green LED on CC3220 Launchpad  //ST365 LED is OFF
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_LED_D9,1);  //Red LED on CC3220 Launchpad
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_LED_D10,1);  //Blue LED on CC3220 Launchpad
        //Let's make LEDs drive low   (ST365 on)            //FLE 20190412
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_LED_D8,0);    //ST365 LED is ON
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_LED_D9,0);
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_LED_D10,0);
        //Let's make Test points drive high
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_TP215,1);  //Set TP215 high
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_TP216,1);
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_TP217,1);
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_TP218,1);
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_TP219,1);
        //Let's make Test points drive the low
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_TP215,0);  //Set TP215 high
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_TP216,0);
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_TP217,0);
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_TP218,0);
            GPIO_write(CC3220SF_LAUNCHXL_GPIO_TP219,0);

  • It is an exception that is trapping the code.

    After single stepping through code I found more accuratly where the code triggers the exception. It is line 7=674 below the MAP function.

  • Hi Forrest,

    You need to call GPIO_init() before you can call any actions for that peripheral. Please see the drivers examples in the SDK, or you can check out the TI Drivers API documentation in the SDK: dev.ti.com/.../node

    Best regards,
    Sarah
  • Bingo Sarah!

    My notes. I looked in the main function and found:

        /* Call board init functions */
        Board_initGeneral();

    I opened the decleration for that function which was in CC3220SF_LAUNCHXL.c and added your reccomended change. It now reads like this:

     *  ======== CC3220SF_LAUNCHXL_initGeneral ========
     */
    void CC3220SF_LAUNCHXL_initGeneral(void)
    {
        PRCMCC3200MCUInit();
        Power_init();
        GPIO_init(); //FLE 20190418
    
        MAP_PRCMPeripheralClkEnable(PRCM_UARTA0, PRCM_RUN_MODE_CLK);
        MAP_PRCMPeripheralClkEnable(PRCM_UARTA1, PRCM_RUN_MODE_CLK);
    
        // Mux Pin62 to mode 1 for outputing NWP logs
        MAP_PinTypeUART(PIN_62, PIN_MODE_1);  // GAA 08May2018 Requested by Tech Support for logging
    
        // Map Pins 6 and 7 to Aux function UART1       STB 27Feb2019
        MAP_PinTypeUART(PIN_07, PIN_MODE_5);
        MAP_PinTypeUART(PIN_08, PIN_MODE_5);
    }

    The project built and ran on the target.

    Any idea why my LEDs on GPIOCC32XX_GPIO_09, GPIOCC32XX_GPIO_10 and GPIOCC32XX_GPIO_11 did not have the same trouble?  I would like to understand why this fix worked.

    Anyway, My problem is resolved.


    Ten thousand thanks.

    Forrest Erickson

  • My problem is resolved so I am marking this resolved.