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