I have an Olimex LPC2378-STK development board and try to connect to my computer with ethernet interface. I am using RL-ARM TCPnet library to send a data using TCP protocol. In NetConfig.c i set up ip and other configurations. But connection with the computer can not be made. The board doesnt respond to ping. In my board ethernet phy is ksz8721bl but in the lpc2378_enet.c dp83848c chip is mentioned. I made some changes in device id etc...
Should i change the lpc2378_enet to suit my phy or can the same code be used? Here is my complete code which can also be wrong...Any idea why i can not connect???
#include <LPC23xx.h> #include <RTL.h> #include <Net_Config.h> #include <stdio.h> #include "lcd.h" #include "ayarlar.h" // Clock & power conf. #define PORT_NUM 80 BOOL tick; U8 socket_tcp; U32 dhcp_tout; char lcd_text[20]; extern LOCALM localm[]; /* Local Machine Settings */ #define MY_IP localm[NETIF_ETH].IpAdr #define DHCP_TOUT 100 /* DHCP timeout 10 seconds */ static void timer_poll() { if(T0IR & 1) { T0IR=1; timer_tick(); tick = __TRUE; } } U16 tcp_callback (U8 soc, U8 event, U8 *ptr, U16 par) { char yaz[3]; if (soc != socket_tcp) { // Error return(0); } switch(event) { case TCP_EVT_DATA: sprintf(yaz,"Data: %d",ptr[0]); // Only 1 byte LCDPutStr(yaz,90,4,SMALL,WHITE,BLACK); break; case TCP_EVT_CONREQ: return (1); case TCP_EVT_CONNECT: break; } return(0); } static void dhcp_check () { if (tick == __FALSE || dhcp_tout == 0) { return; } tick = __FALSE; if (mem_test(&MY_IP, 0, IP_ADRLEN) == __FALSE && !(dhcp_tout & 0x80000000)) { // Success, DHCP has already got the IP address. dhcp_tout = 0; LCDPutStr("IP address:",100,4,SMALL,WHITE,BLACK); sprintf(lcd_text,"%d.%d.%d.%d", MY_IP[0], MY_IP[1], MY_IP[2], MY_IP[3]); LCDPutStr(lcd_text,115,4,SMALL,WHITE,BLACK); return; } if (--dhcp_tout == 0) { // A timeout, disable DHCP and use static IP address. dhcp_disable (); LCDPutStr("DHCP Failed",85,4,SMALL,WHITE,BLACK); dhcp_tout = 30 | 0x80000000; return; } if (dhcp_tout == 0x80000000) { dhcp_tout = 0; LCDPutStr("IP address:",100,4,SMALL,WHITE,BLACK); sprintf(lcd_text,"%d.%d.%d.%d", MY_IP[0], MY_IP[1], MY_IP[2], MY_IP[3]); LCDPutStr(lcd_text,115,4,SMALL,WHITE,BLACK); } } void Tick_Hazirla(void) { T0MR0=0x006DDD00; T0MCR=3; T0IR=1; T0TCR=1; } int main(void) { Clk_Ayar(CPU_CLK_72_MHZ); // Clk conf. Tick_Hazirla(); InitLcd(); LCDClearScreen(WHITE); LCDPutStr("Initializing...",10,4,SMALL,WHITE,BLACK); LCDPutStr("TCP starting...",25,4,SMALL,WHITE,BLACK); init_TcpNet(); socket_tcp=tcp_get_socket(TCP_TYPE_SERVER, 0, 10, tcp_callback); if (socket_tcp!=0) { if(tcp_listen(socket_tcp, PORT_NUM)==__TRUE) LCDPutStr("TCP listen ready !",40,4,SMALL,WHITE,BLACK); else LCDPutStr("TCP listen failed !",40,4,SMALL,WHITE,BLACK); } dhcp_tout = DHCP_TOUT; while(1) { timer_poll(); main_TcpNet(); dhcp_check(); } }