Tool/software: Code Composer Studio
I am having a similar problem using static IP. My computer IP is 192.168.101.11 and the DK board is 192.168.101.10. I am able to ping 192.168.101.10 from my computer but I can't get the UDP to output.
//*****************************************************************************
//
// This example demonstrates the use of the Ethernet Controller.
//
//*****************************************************************************
main(void)
{
uint32_t ui32User0, ui32User1;
uint8_t pui8MACArray[8];
struct ip_addr ipAddr;
struct ip_addr ipAddr2;
struct ip_addr subnet;
struct ip_addr gateway;
char errorFlag;
struct udp_pcb *UDPSock;
ipAddr.addr = (192u << 24) | (168u << 16) | (101u << 8) | 10u;
ipAddr2.addr = (192u << 24) | (168u << 16) | (101u << 8) | 11u;
subnet.addr = (255u << 24) | (255u << 16) | (255u << 8) | 0;
// gateway = (192u << 24) | (168u << 16) | (0u << 8) | 1;
// IP4_ADDR(&ipAddr, 192, 168, 101, 10);
// IP4_ADDR(&subnet, 255, 255, 255, 0);
IP4_ADDR(&gateway, 0, 0, 0, 0);
//
// Run from the PLL at 120 MHz.
//
g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
SYSCTL_OSC_MAIN | SYSCTL_USE_PLL |
SYSCTL_CFG_VCO_480), 120000000);
//
// Configure the device pins.
//
PinoutSet();
//
// Initialize the display driver.
//
Kentec320x240x16_SSD2119Init(g_ui32SysClock);
//
// Initialize the graphics context.
//
GrContextInit(&g_sContext, &g_sKentec320x240x16_SSD2119);
//
// Draw the application frame.
//
FrameDraw(&g_sContext, "enet-static");
//
// Configure SysTick for a periodic interrupt.
//
ROM_SysTickPeriodSet(g_ui32SysClock / SYSTICKHZ);
ROM_SysTickEnable();
ROM_SysTickIntEnable();
//
// Initialize the file system.
//
fs_init();
//
// Configure the hardware MAC address for Ethernet Controller filtering of
// incoming packets. The MAC address will be stored in the non-volatile
// USER0 and USER1 registers.
//
ROM_FlashUserGet(&ui32User0, &ui32User1);
if((ui32User0 == 0xffffffff) || (ui32User1 == 0xffffffff))
{
//
// We should never get here. This is an error if the MAC address has
// not been programmed into the device. Exit the program.
//
GrContextForegroundSet(&g_sContext, ClrRed);
GrStringDrawCentered(&g_sContext, "MAC Address", -1,
GrContextDpyWidthGet(&g_sContext) / 2,
(GrContextDpyHeightGet(&g_sContext) / 2) - 4,
false);
GrStringDrawCentered(&g_sContext, "Not Programmed!", -1,
GrContextDpyWidthGet(&g_sContext) / 2,
(GrContextDpyHeightGet(&g_sContext) / 2) + 16,
false);
while(1)
{
}
}
//
// Convert the 24/24 split MAC address from NV ram into a 32/16 split MAC
// address needed to program the hardware registers, then program the MAC
// address into the Ethernet Controller registers.
//
pui8MACArray[0] = ((ui32User0 >> 0) & 0xff);
pui8MACArray[1] = ((ui32User0 >> 8) & 0xff);
pui8MACArray[2] = ((ui32User0 >> 16) & 0xff);
pui8MACArray[3] = ((ui32User1 >> 0) & 0xff);
pui8MACArray[4] = ((ui32User1 >> 8) & 0xff);
pui8MACArray[5] = ((ui32User1 >> 16) & 0xff);
//
// Initialze the lwIP library, using DHCP.
//
lwIPInit(g_ui32SysClock, pui8MACArray, ipAddr.addr, subnet.addr, gateway.addr, IPADDR_USE_STATIC);
UDPSock = udp_new();
udp_recv(UDPSock, NULL, NULL);
errorFlag = udp_bind(UDPSock, &ipAddr, 7070);
if (errorFlag)
errorFlag = 0;
// errorFlag = udp_connect(UDPSock, IP_ADDR_ANY, 7070);
// if (errorFlag)
// errorFlag = 0;
char buf[500] = "HELLO KITTY";
struct pbuf *p = 0;
//struct ip_addr server;
// IP4_ADDR(&server, 192, 168, 253, 236);
//
//
// Setup the device locator service.
//
//LocatorInit();
//LocatorMACAddrSet(pui8MACArray);
//LocatorAppTitleSet("DK-TM4C129X enet_lwip");
//
// Initialize the sample httpd server.
//
//httpd_init();
//
// Set the interrupt priorities. We set the SysTick interrupt to a higher
// priority than the Ethernet interrupt to ensure that the file system
// tick is processed if SysTick occurs while the Ethernet handler is being
// processed. This is very likely since all the TCP/IP and HTTP work is
// done in the context of the Ethernet interrupt.
//
ROM_IntPrioritySet(INT_EMAC0, ETHERNET_INT_PRIORITY);
ROM_IntPrioritySet(FAULT_SYSTICK, SYSTICK_INT_PRIORITY);
uint32_t ui32Loop;
//
// Loop forever. All the work is done in interrupt handlers.
//
while(1)
{
p=pbuf_alloc(PBUF_TRANSPORT, 500, PBUF_RAM);
memcpy(p->payload, buf, 500);
errorFlag = udp_sendto(UDPSock,p, &ipAddr2, 7070);
if (errorFlag)
errorFlag = 0;
pbuf_free(p);
for(ui32Loop = 0; ui32Loop < 2000000; ui32Loop++)
{}
}
}