Hi everybody,
I'm trying to use my concerto control card with the F28M35H51C device as a client in a Client-Server system connected through ethernet (in this case the server is my PC). I started from enet_uip example, but in this example the concerto control card works as a server. Once I have tested successfully the enet_uip example i tried to change it to work as a client; here is the main function code:
int main(void) { uip_ipaddr_t ipaddr; static struct uip_eth_addr sTempAddr; long lPeriodicTimer, lARPTimer; unsigned long ulUser0, ulUser1; unsigned long ulTemp; int command_word; // Disable Protection HWREG(SYSCTL_MWRALLOW) = 0xA5A5A5A5; // Sets up PLL, M3 running at 75MHz and C28 running at 150MHz SysCtlClockConfigSet(SYSCTL_USE_PLL | (SYSCTL_SPLLIMULT_M & 0xF) | SYSCTL_SYSDIV_1 | SYSCTL_M3SSDIV_2 | SYSCTL_XCLKDIV_4); #ifdef _FLASH // Copy time critical code and Flash setup code to RAM // This includes the following functions: InitFlash(); // The RamfuncsLoadStart, RamfuncsLoadSize, and RamfuncsRunStart // symbols are created by the linker. Refer to the device .cmd file. memcpy(&RamfuncsRunStart, &RamfuncsLoadStart, (size_t)&RamfuncsLoadSize); // Call Flash Initialization to setup flash waitstates // This function must reside in RAM FlashInit(); #endif PinoutSet(); // Enable clock supply for the following peripherals SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); SysCtlPeripheralEnable(SYSCTL_PERIPH_ETH); // Disable clock supply for the watchdog modules SysCtlPeripheralDisable(SYSCTL_PERIPH_WDOG1); SysCtlPeripheralDisable(SYSCTL_PERIPH_WDOG0); // Adjust the pointer to be aligned on an odd half word address so that // DMA can be used. uip_buf = (u8_t *)(((unsigned long)ucUIPBuffer + 3) & 0xfffffffe); // Enable the uDMA controller and set up the control table base. SysCtlPeripheralEnable(SYSCTL_PERIPH_UDMA); uDMAEnable(); uDMAControlBaseSet(g_sDMAControlTable); // Configure the DMA TX channel uDMAChannelAttributeDisable(UDMA_CHANNEL_ETH0TX, UDMA_ATTR_ALL); uDMAChannelControlSet(UDMA_CHANNEL_ETH0TX, UDMA_SIZE_32 | UDMA_SRC_INC_32 | UDMA_DST_INC_NONE | UDMA_ARB_8); // Set user/company specific MAC octets // (for this code we are using A8-63-F2-00-00-80) // 0x00 MACOCT3 MACOCT2 MACOCT1 ulUser0 = 0x00F263A8; // 0x00 MACOCT6 MACOCT5 MACOCT4 ulUser1 = 0x00800000; // User needs to program user specific MAC address into Flash // and read it on power up if((ulUser0 == 0xffffffff) || (ulUser1 == 0xffffffff)) { // We should never get here. This is an error if the MAC address has // not been programmed into the device. Exit the program. while(1) { } } // Enable and Reset the Ethernet Controller. SysCtlPeripheralEnable(SYSCTL_PERIPH_ETH); SysCtlPeripheralReset(SYSCTL_PERIPH_ETH); // Configure SysTick for a periodic interrupt. SysTickPeriodSet(SysCtlClockGet(SYSTEM_CLOCK_SPEED) / SYSTICKHZ); SysTickEnable(); IntRegister(FAULT_SYSTICK, SysTickIntHandler); SysTickIntEnable(); // Configure the DMA channel for Ethernet receive. uDMAChannelAttributeDisable(UDMA_CHANNEL_ETH0RX, UDMA_ATTR_ALL); uDMAChannelControlSet(UDMA_CHANNEL_ETH0RX, UDMA_SIZE_32 | UDMA_SRC_INC_NONE | UDMA_DST_INC_32 | UDMA_ARB_8); // Initialize the Ethernet Controller and disable all Ethernet Controller // interrupt sources. EthernetIntDisable(ETH_BASE, (ETH_INT_PHY | ETH_INT_MDIO | ETH_INT_RXER | ETH_INT_RXOF | ETH_INT_TX | ETH_INT_TXER | ETH_INT_RX)); ulTemp = EthernetIntStatus(ETH_BASE, false); EthernetIntClear(ETH_BASE, ulTemp); // Initialize the Ethernet Controller for operation. EthernetInitExpClk(ETH_BASE, SysCtlClockGet(SYSTEM_CLOCK_SPEED)); // Configure the Ethernet Controller for normal operation. // - Full Duplex // - TX CRC Auto Generation // - TX Padding Enabled EthernetConfigSet(ETH_BASE, (ETH_CFG_TX_DPLXEN | ETH_CFG_TX_CRCEN | ETH_CFG_TX_PADEN)); // Wait for the link to become active. while((EthernetPHYRead(ETH_BASE, PHY_MR1) & 0x0004) == 0) { } // Enable the Ethernet Controller. EthernetEnable(ETH_BASE); // Enable and register the Ethernet interrupt. IntRegister(INT_ETH, EthernetIntHandler); IntEnable(INT_ETH); #ifndef REV_0_SILICON IntRegister(INT_UDMA, EthernetIntHandler); IntEnable(INT_UDMA); #endif // Enable the Ethernet RX Packet interrupt source. EthernetIntEnable(ETH_BASE, ETH_INT_RX); // Enable all processor interrupts. IntMasterEnable(); // Initialize the uIP TCP/IP stack. uip_init(); #ifdef USE_STATIC_IP uip_ipaddr(ipaddr, DEFAULT_IPADDR0, DEFAULT_IPADDR1, DEFAULT_IPADDR2, DEFAULT_IPADDR3); uip_sethostaddr(ipaddr); ShowIPAddress(ipaddr); uip_ipaddr(ipaddr, DEFAULT_NETMASK0, DEFAULT_NETMASK1, DEFAULT_NETMASK2, DEFAULT_NETMASK3); uip_setnetmask(ipaddr); #else uip_ipaddr(ipaddr, 0, 0, 0, 0); uip_sethostaddr(ipaddr); uip_ipaddr(ipaddr, 0, 0, 0, 0); uip_setnetmask(ipaddr); #endif // Convert the 24/24 split MAC address from ram into a 32/16 split MAC // address needed to program the hardware registers, then program the MAC // address into the Ethernet Controller registers. sTempAddr.addr[0] = ((ulUser0 >> 0) & 0xff); sTempAddr.addr[1] = ((ulUser0 >> 8) & 0xff); sTempAddr.addr[2] = ((ulUser0 >> 16) & 0xff); sTempAddr.addr[3] = ((ulUser1 >> 0) & 0xff); sTempAddr.addr[4] = ((ulUser1 >> 8) & 0xff); sTempAddr.addr[5] = ((ulUser1 >> 16) & 0xff); // Program the hardware with it's MAC address (for filtering). EthernetMACAddrSet(ETH_BASE, (unsigned char *)&sTempAddr); uip_setethaddr(sTempAddr); #ifndef USE_STATIC_IP // Initialize the DHCP Client Application. dhcpc_init(&sTempAddr.addr[0], 6); dhcpc_request(); #endif // Main Application Loop. lPeriodicTimer = 0; lARPTimer = 0; uip_ipaddr(&ipaddr, 169, 254, 42, 86); uip_connect(&ipaddr, HTONS(80)); if(uip_connected()){ while(true) { } } else{ for(;;){} } }
I can see in the debugger that the host is not connected because the application falls in the infinite for loop.
To see what is happening on the ethernet port I'm using the software WireShark and i can see some traffic on the ethernet port, (PC is sending some packets, but destination IP is not the IP of concerto). Do you have any idea of how I can solve that? Or are there some examples of how Concerto works as client?
Thank you in advance and regards,
Filipp