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.

CCS/CC3220SF-LAUNCHXL: fault ISR error when writing to gpio ports

Part Number: CC3220SF-LAUNCHXL

Tool/software: Code Composer Studio

Hello,

In my application, I need to write to gpio port pins with pointers (as opposed to using GPIO_write or GPIO_setConfig functions) in order to speed up the program. Sometimes on startup, I get a fault ISR error on the line of code that sets the gpio pin using pointers. However, if I change the code to set the pin with GPIO_write or GPIO_setConfig functions, I don't get a fault ISR error, and the next time I run the code with the pointer syntax, I don't get an error anymore. I can't figure out what is causing the error in the first place, or why it goes away after I use the GPIO_write or GPIO_setConfig functions.

Here is a section of code where I use pointers to set the GPIO port direction, set the write enable pin, and send a message through the GPIO registers:

*gpioDir = 0xff ; // Set Port1 to all outputs
for (i=0;i<bytesRcvd;i++) {
    *gpioReg = buffer[i] ; // write word to gpio pins
    *gpioWifiClk = GPIO_WIFI_CLK_SET_VALUE ;
    *gpioWifiClk = 0 ;
}
*gpioWrEn = 0 ; // wrEn = 1

Here is a section of code that does the same as above, but uses the GPIO_write or GPIO_setConfig functions:

for (i=0;i<8;i++) {
    /* Configure port for output */
    GPIO_setConfig(i, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW | GPIO_CFG_OUT_STR_HIGH);
}
*/ set write enable */
GPIO_setConfig(9, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW | GPIO_CFG_OUT_STR_HIGH);
GPIO_write(9,1) ;
for (i=0;i<bytesRcvd;i++) {
    for (j=0;j<8;j++) {
        /* Configure port for output */
        GPIO_write(j, (buffer[i] >> j) & 0x01 );
    }
}
*/ unset write enable */
GPIO_write(9,0) ;

Thanks,

Michelle Hedlund

  • Hi Michelle,

    Could you show me how you are declaring the pointers? I want to understand how exactly you are trying to get better time performance.

    Jesu

  • Hi Jesu,

    Yes, here are the pointer declarations:

    volatile unsigned int *gpioReg = (unsigned int*)0x400053FC ; // Address for 8 bits of port A1 (see TRM Chapter 5.5.1 and OneNote -> WHD -> TI SimpleLink SugarCube Application)
    volatile unsigned int *gpioDir = (unsigned int*)0x40005400 ; // Address for GPIODIR for port A1 (see TRM Chapter 5.5.2)
    volatile unsigned int *gpioWrEn = (unsigned int*)0x40006008 ; // Address for GPIO17 for port A2.1 0x40006 0000 0000 1000 = 0x40006008 (see TRM Chapter 5.5.1)
    #define GPIO_WR_EN_SET_VALUE 2 // 2^1
    volatile unsigned int *gpioRdEn = (unsigned int*)0x40007040 ; // Address for GPIO28 for port A3.4 0x40007 0000 0100 0000 = 0x40007040 (see TRM Chapter 5.5.1)
    #define GPIO_RD_EN_SET_VALUE 16 // 2^4
    volatile unsigned int *gpioWifiClk = (unsigned int*)0x40007100 ; // Address for GPIO30 for port A3.6 0x40007 0001 0000 0000 = 0x40007100 (see TRM Chapter 5.5.1)
    #define GPIO_WIFI_CLK_SET_VALUE 64 // 2^6
    volatile unsigned int *gpioEmpty = (unsigned int*)0x40006100 ; // Address for GPIO22 for port A2.6 0x40006 0001 0000 0000 = 0x40006100 (see TRM Chapter 5.5.1)

  • Thank you for providing this. I see you are trying to write directly to the port registers. Out of curiosity, if you add a delay on startup do you still get a fault ISR? Maybe it has something to do with initialization.

    Jesu