How to connect the ethernet in lpc1768 board

cancel
Showing results for 
Search instead for 
Did you mean: 

How to connect the ethernet in lpc1768 board

61 Views
Mamatha-12
Contributor I

Hi,

I'm working LPC1768 board to communicate the ethernet.

I'm new to this topic, i have sample code downloaded from the LwIP lpcopen in that peri-ethernet i used

but I'm able to connect the ethernet to my board. I can't able to see the board name in the tp link.

can any one suggest me.

 

 

int main(void) {

uint8_t macaddr[6];
uint8_t *workbuff;
int32_t rxBytes, i;
uint32_t physts;
bool ethpkttgl = true;
volatile int k = 1;
ip_addr_t ipaddr, netmask, gw;
static int prt_ip = 0;
SystemInit();
//SysTick_Enable(1);
SystemCoreClockUpdate();
Board_Init();
HardwareInit();
LPC_PINCON->PINSEL1 &= (~(3 << 12));
LPC_GPIO1->FIODIR |= 1<<29; //
LPC_GPIO0->FIODIR |= 1<<21; //
LPC_GPIO1->FIOCLR |= 1<<29;

// SysTick_Init(); /* Initialize SysTick for 1ms(default)*/
// SysTick_AttachInterrupt(myIsr); /* myIsr will be called by SysTick_Handler every ms */
// SysTick_Start(); /* Start SysTick Timer */
/* Setup ethernet and PHY */
#if defined(USE_RMII)
Chip_ENET_Init(LPC_ETHERNET, true);

#else
Chip_ENET_Init(LPC_ETHERNET, false);
#endif

/* Setup MII clock rate and PHY address */
Chip_ENET_SetupMII(LPC_ETHERNET, Chip_ENET_FindMIIDiv(LPC_ETHERNET, 2500000), 1);

lpc_phy_init(true, localMsDelay);

// /* Setup MAC address for device */
// Board_ENET_GetMacADDR(macaddr);
// Chip_ENET_SetADDR(LPC_ETHERNET, macaddr);

/* Setup descriptors */
// InitDescriptors();
// /* Enable RX/TX after descriptors are setup */
// Chip_ENET_TXEnable(LPC_ETHERNET);
// Chip_ENET_RXEnable(LPC_ETHERNET);

/* Initialize LWIP */
lwip_init();

//LWIP_DEBUGF(LWIP_DBG_ON, ("Starting LWIP TCP echo server...\n"));

/* Static IP assignment */
#if LWIP_DHCP
IP4_ADDR(&gw, 0, 0, 0, 0);
IP4_ADDR(&ipaddr, 0, 0, 0, 0);
IP4_ADDR(&netmask, 0, 0, 0, 0);
#else
IP4_ADDR(&gw, 10, 1, 10, 1);
IP4_ADDR(&ipaddr, 10, 1, 10, 234);
IP4_ADDR(&netmask, 255, 255, 255, 0);
APP_PRINT_IP(&ipaddr);
#endif

netif_add(&lpc_netif, &ipaddr, &netmask, &gw, NULL, lpc_enetif_init,
ethernet_input);
netif_set_default(&lpc_netif);
netif_set_up(&lpc_netif);
#if LWIP_DHCP
dhcp_start(&lpc_netif);
#endif

while (1)
{

workbuff = ENET_RXGet(&rxBytes);
if (workbuff) {
/* Packet was received. Dump some info from the packet */
// DEBUGOUT("Packet received: ");
ethpkttgl = (bool) !ethpkttgl;

/* Toggle LED2 on each packet received */
//Board_LED_Set(1, ethpkttgl);

/* Destination and source MAC addresses */
// printf("-Dest MAC: %02x:%02x:%02x:%02x:%02x:%02x-",
// workbuff[0], workbuff[1], workbuff[2], workbuff[3], workbuff[4], workbuff[5]);
// DEBUGOUT("-Source MAC: %02x:%02x:%02x:%02x:%02x:%02x-",
// workbuff[6], workbuff[7], workbuff[8], workbuff[9], workbuff[10], workbuff[11]);
//
// /* Length of received packet and embedded len/type */
// DEBUGOUT("-Packet len: %d", rxBytes);
// DEBUGOUT("-Type: %04x\r\n", ((((uint32_t) workbuff[12]) << | (((uint32_t) workbuff[13]))));
//ENET_RXBuffClaim();
}
/* Send a 'dummy' broadcast packet on a keypress. You'll only see this
if your using a tool such as WireShark and the packet will not have
a checksum */

// //LPC_GPIO1->FIOPIN ^= (1<<29); /* Toggle */
lpc_enetif_input(&lpc_netif);
/* lpc_rx_queue will re-qeueu receive buffers. This normally occurs
automatically, but in systems were memory is constrained, pbufs
may not always be able to get allocated, so this function can be
optionally enabled to re-queue receive buffers. */
#if 0
while (lpc_rx_queue(&lpc_netif)) {}
#endif

/* Free TX buffers that are done sending */
lpc_tx_reclaim(&lpc_netif);

/* LWIP timers - ARP, DHCP, TCP, etc. */
sys_check_timeouts();

/* Call the PHY status update state machine once in a while
to keep the link status up-to-date */
physts = lpcPHYStsPoll();
if (physts & PHY_LINK_CHANGED) {
if (physts & PHY_LINK_CONNECTED) {
//Board_LED_Set(0, true);
LPC_GPIO1->FIOSET |= 1<<29;
prt_ip = 0;

/* Set interface speed and duplex */
if (physts & PHY_LINK_SPEED100) {
Chip_ENET_Set100Mbps(LPC_ETHERNET);
NETIF_INIT_SNMP(&lpc_netif, snmp_ifType_ethernet_csmacd, 100000000);
}
else {
Chip_ENET_Set10Mbps(LPC_ETHERNET);
NETIF_INIT_SNMP(&lpc_netif, snmp_ifType_ethernet_csmacd, 10000000);
}
if (physts & PHY_LINK_FULLDUPLX) {
Chip_ENET_SetFullDuplex(LPC_ETHERNET);
}
else {
Chip_ENET_SetHalfDuplex(LPC_ETHERNET);
}

netif_set_link_up(&lpc_netif);
}
else {
LPC_GPIO1->FIOCLR |= 1<<29;
netif_set_link_down(&lpc_netif);
}

//DEBUGOUT("Link connect status: %d\r\n", ((physts & PHY_LINK_CONNECTED) != 0));
}


}

return 0 ;
}

Thank you.

0 Kudos
2 Replies

48 Views
FelipeGarcia
NXP TechSupport
NXP TechSupport

Hi,

I am assuming you are using your custom board, correct? Please note that our evaluation boards needs to connect with base board for using RS232/UART port and Ethernet port.

If you are using custom board, could you please try to replicate this in our board so I can do tests about this on my side as well?

Best regards,

Felipe

0 Kudos

41 Views
Mamatha-12
Contributor I

Hi,

Thank you for reply,

now i can able to connect the ethernet port to my custom board (lpc1768 ).

i can able to send the data socket test app through tcpip.now i'm facing the issue whatever i send the data through tcpip same data i want to send the upper level (DoIP ).can you please suggest me.

thank you. 

0 Kudos