Part Number:MSP432E401Y
Tool/software: TI-RTOS
I'm using the MSP_EXP432E401Y development board and I wanted to initialize a static IP based TCP stack. I've been successful in this and have been running tests for several weeks.
Now I want to allow for the static IP that's assigned to be determined by a jumper position on the development board so that we can interchange the part on different network topologies that may post IP conflicts on one IP or another. To do this, I initialized pin PD2 on the development board, configured it with a pull up resistor and applied a jumper cable that can be either disconnected (pin reads high) or connected to ground (pin reads low). Now I want to read the pin during the IP initialization routine and choose an IP address variable based on the state of the jumper.
The problem I run into is that the program freezes anytime it gets to the part of the IP initialization routine where it must read the GPIO pin using GPIO_read(*pin*).
I've seen that I can easily read the pin within the a pthread routine I have running where it will constantly print out the jumper status (pin state high or low) and do so accurately, so I know that there isn't a problem with the configuration of the pin, it must be something in how the system processes the GPIO_read command during the ndk startup scripts.
Interestingly enough, while debugging, I've seen that a UART display call (Display_printf) will also hang in these same spots as well. The system will print a partial string to the debug console and then freeze, so the problem may not be specific to the GPIO calls.
Doing a debug trace I see that in either case the program will enter a Hwi while loop under the Hwi_execHandler() function where it appears that Hwi_execHandlerFunc == NULL always returns true.
The help doc tells me that this is determined somehow by the value of Hwi.enableException. So I'm guessing that, first, there is some sort of exception being thrown and second, I'm not sure how to handle this.
Any advice would be appreciated.
I'm basically using a modified version of the tcpEcho tirtos example with the initIP function in the ndk_tirtos replaced with the following code.
/*
* ======== initStaticIp ========
* Configure the stack's IP settings
*/
static void initStaticIp(void *hCfg)
{
const char *localIPAddr1 = "192.168.0.31";
const char *localIPAddr2 = "192.168.0.32";
const char *localIPMask = "255.255.255.0";
const char *gatewayIP = "192.168.0.1";
const char *domainName = "demo.net";
CI_IPNET netAddr;
CI_ROUTE route;
/* Add global hostname to hCfg (to be claimed in all connected domains) */
CfgAddEntry(hCfg, CFGTAG_SYSINFO, CFGITEM_DHCP_HOSTNAME, 0,
strlen(hostName), (unsigned char *)hostName, NULL);
/* Configure static IP address on interface 1 */
memset(&netAddr, 0, sizeof(netAddr));
if(GPIO_read(IPSwitch) != 0) {netAddr.IPAddr = inet_addr(localIPAddr1);}
else{netAddr.IPAddr = inet_addr(localIPAddr2);}
netAddr.IPAddr = inet_addr(localIPAddr1);
netAddr.IPMask = inet_addr(localIPMask);
strcpy(netAddr.Domain, domainName);
netAddr.NetType = CFG_NETTYPE_VIRTUAL;
CfgAddEntry(hCfg, CFGTAG_IPNET, 1, 0,
sizeof(netAddr), (unsigned char *)&netAddr, NULL);
/* Add default gateway. Since it's the default gateway, the destination
* address and mask are both zero. */
memset(&route, 0, sizeof(route));
route.IPDestAddr = 0;
route.IPDestMask = 0;
route.IPGateAddr = inet_addr(gatewayIP);
CfgAddEntry(hCfg, CFGTAG_ROUTE, 0, 0,
sizeof(route), (unsigned char *)&route, NULL);
}
and the modified GPIO_PinConfig in the MSP_EXPE401Y.c file is as follows, with the IP Jumper being the relevant GPIO pin:
GPIO_PinConfig gpioPinConfigs[] = {
/* Push Buttons */
/* MSP_EXP432E401Y_USR_SW1 */
GPIOMSP432E4_PJ0 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
/* MSP_EXP432E401Y_USR_SW2 */
GPIOMSP432E4_PJ1 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_RISING,
/* MSP_EXP432E401Y_SPI_MASTER_READY */
GPIOMSP432E4_PM3 | GPIO_DO_NOT_CONFIG,
/* MSP_EXP432E401Y_SPI_SLAVE_READY */
GPIOMSP432E4_PL0 | GPIO_DO_NOT_CONFIG,
/* Onboard LED Output */
/* MSP_EXP432E401Y_USR_D1 */
GPIOMSP432E4_PN1 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
/* MSP_EXP432E401Y_USR_D2 */
GPIOMSP432E4_PN0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
/* MSP_EXP432E401Y_USR_D3 */
GPIOMSP432E4_PF4 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
/* MSP_EXP432E401Y_USR_D4 */
GPIOMSP432E4_PF0 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
/* HV Digital I/O */
/* Anode Enable (1 = LOW) */
GPIOMSP432E4_PL2 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_HIGH,
/* Cathode Enable (1 = LOW) */
GPIOMSP432E4_PN3 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_HIGH,
/* Anticathode Enable (1 = LOW) */
GPIOMSP432E4_PL3 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_HIGH,
/* HV Enable (0 = LOW) */
GPIOMSP432E4_PP2 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_LOW,
/* IP Jumper */
GPIOMSP432E4_PD2 | GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_NONE,
/* MSP_EXP432E401Y_SDSPI_CS */
GPIOMSP432E4_PC7 | GPIO_CFG_OUT_STD | GPIO_CFG_OUT_STR_HIGH | GPIO_CFG_OUT_HIGH,
/* Sharp Display - GPIO configurations will be done in the Display files */
GPIOMSP432E4_PE5 | GPIO_DO_NOT_CONFIG, /* SPI chip select */
GPIOMSP432E4_PC6 | GPIO_DO_NOT_CONFIG, /* LCD power control */
GPIOMSP432E4_PE4 | GPIO_DO_NOT_CONFIG, /*LCD enable */
};
The enum in the MSP_EXP432E401Y.h file is as follows:
typedef enum MSP_EXP432E401Y_GPIOName {
/* Push Buttons */
MSP_EXP432E401Y_GPIO_USR_SW1 = 0,
MSP_EXP432E401Y_GPIO_USR_SW2,
/* SPI - not configured */
MSP_EXP432E401Y_SPI_MASTER_READY,
MSP_EXP432E401Y_SPI_SLAVE_READY,
/* oOnboard LED Outputs */
MSP_EXP432E401Y_GPIO_LED_D1,
MSP_EXP432E401Y_GPIO_LED_D2,
MSP_EXP432E401Y_GPIO_LED_D3,
MSP_EXP432E401Y_GPIO_LED_D4,
/* HV Digital I/O */
MSP_EXP432E401Y_GPIO_L2,
MSP_EXP432E401Y_GPIO_N3,
MSP_EXP432E401Y_GPIO_L3,
MSP_EXP432E401Y_GPIO_P2,
/* IP Jumper */
MSP_EXP432E401Y_GPIO_D2,
/* MSP_EXP432E401Y_SDSPI_CS */
MSP_EXP432E401Y_SDSPI_CS,
/* Sharp 96x96 LCD Pins - not configured*/
MSP_EXP432E401Y_LCD_CS,
MSP_EXP432E401Y_LCD_POWER,
MSP_EXP432E401Y_LCD_ENABLE,
MSP_EXP432E401Y_GPIOCOUNT
} MSP_EXP432E401Y_GPIOName;
And lastly, the board.h file has the following #define:
#define IPSwitch MSP_EXP432E401Y_GPIO_D2