Good evening, I have laid out a pcb with an W5500 and an Atmega256RFR2, the W5500 implementation is straight from the example using the jack with magnetics for a smaller footprint, after some initial problems with the SPI config I can talk with the chip via SPI and do the init routine, but whatever I do/change in code I can’t get it so send back even one single packet back(I have been monitorizing the ethernet with Wireshark).
I have already tried a couple “libs” that build on top of Wiznet own lib/driver, but none gets me anywhere.
My printf inside TCP_Server always returns 0x14 and nothing else, reading back the NetConf values from the chip with TCP_Server running in the main loop I get this:
=== NET CONF : STATIC ===
====== HW ID : 4 ======
MAC : 00:14:A3:72:17:3F
IP : 192.168.1.2
GW : 192.168.1.1
SN : 255.255.255.0
=======================================
I really cant understand if this an hardware fail, or some software problem, I can probe the TX+/- and RX+/- lines that go to the mag jack, but with a 100Mhz scope I cant really “see” anything right or wrong with them, if I disconnect the cable I can see a series os pulses on TXN/TXP and nothing on RXP/RXN, expected, at least from my understanding.
I will also attach a couple print-screens from my layout and schematic.
About that, I swaped MISO and MOSI lines(dohh), already taken care of, and forgot the load caps on the 25Mhz crystal because I had an oscillator in there first, the caps where also added right next to the crystal and its indeed oscillating at 25Mhz.
Using this code:
[code]void TCP_Server(void){
int32_t ret;
uint16_t size = 0, sentsize = 0;
int16_t funcVal = 0;
//uartPutsP("\nTCP_Server\n");
// Get status of socket
funcVal = getSn_SR(SOCK_ID_TCP);
sprintf(gPtrintBuff, "\ngetSn_SR(%i): %#02x\n", SOCK_ID_TCP, funcVal);
uartPuts(gPtrintBuff);
switch(funcVal){
// Connection established
case SOCK_ESTABLISHED :{
uartPutsP("\nScoket estabilished\n");
// Check interrupt: connection with peer is successful
if(getSn_IR(SOCK_ID_TCP) & Sn_IR_CON){
// Clear corresponding bit
setSn_IR(SOCK_ID_TCP,Sn_IR_CON);
}
// Get received data size
if((size = getSn_RX_RSR(SOCK_ID_TCP)) > 0){
// Cut data to size of data buffer
if(size > DATA_BUF_SIZE){
size = DATA_BUF_SIZE;
}
// Get received data
ret = recv(SOCK_ID_TCP, gDATABUF, size);
// Check for error
if(ret <= 0){
return;
}
// Send echo to remote
sentsize = 0;
while(size != sentsize){
ret = send(SOCK_ID_TCP, gDATABUF + sentsize, size - sentsize);
// Check if remote close socket
if(ret < 0){
close(SOCK_ID_TCP);
return;
}
// Update number of sent bytes
sentsize += ret;
}
}
break;
}
// Socket received the disconnect-request (FIN packet) from the connected peer
case SOCK_CLOSE_WAIT :{
// Disconnect socket
if((ret = disconnect(SOCK_ID_TCP)) != SOCK_OK){
return;
}
break;
}
// Socket is opened with TCP mode
case SOCK_INIT :{
uartPutsP("SOCK_INIT\n");
// Listen to connection request
if( (ret = listen(SOCK_ID_TCP)) != SOCK_OK){
return;
}
break;
}
// Socket is released
case SOCK_CLOSED:{
// Open TCP socket
if((ret = socket(SOCK_ID_TCP, Sn_MR_TCP, PORT_TCP, 0x00)) != SOCK_ID_TCP){
return;
}
break;
}
default:{
break;
}
}
}
// brief Handle UDP socket state.
void UDP_Server(void)
{
int32_t ret;
uint16_t size, sentsize;
uint8_t destip[4];
uint16_t destport;
// Get status of socket
switch(getSn_SR(SOCK_ID_UDP)){
// Socket is opened in UDP mode
case SOCK_UDP:{
// Get received data size
if((size = getSn_RX_RSR(SOCK_ID_UDP)) > 0){
// Cut data to size of data buffer
if(size > DATA_BUF_SIZE){
size = DATA_BUF_SIZE;
}
// Get received data
ret = recvfrom(SOCK_ID_UDP, gDATABUF, size, destip, (uint16_t*)&destport);
// Check for error
if(ret <= 0){
return;
}
// Send echo to remote
size = (uint16_t) ret;
sentsize = 0;
while(sentsize != size){
ret = sendto(SOCK_ID_UDP, gDATABUF + sentsize, size - sentsize, destip, destport);
if(ret < 0){
return;
}
// Update number of sent bytes
sentsize += ret;
}
}
break;
}
// Socket is not opened
case SOCK_CLOSED:{
// Open UDP socket
if((ret=socket(SOCK_ID_UDP, Sn_MR_UDP, PORT_UDP, 0x00)) != SOCK_ID_UDP){
return;
}
break;
}
default :{
break;
}
}
}
// brief Initialize modules
static void W5500_Init(void){
// Set Tx and Rx buffer size to 2KB
uint8_t buffsize[8] = { 2, 2, 2, 2, 2, 2, 2, 2 };
// Reset module
PMOD_PORT &= ~_BV(RST_W5500); //Set Rst low
_delay_ms(500); //Minimun of 500us, 10ms to be safe
PMOD_PORT |= _BV(RST_W5500); //Set rst high
_delay_ms(1);
// Wizchip initialize
wizchip_init(buffsize, buffsize, 0, 0, cs_sel, cs_desel, 0, 0, spi_rb, spi_wb);
// Wizchip netconf
ctlnetwork(CN_SET_NETINFO, (void*) &gWIZNETINFO);
ctlwizchip(CW_SET_PHYCONF, (void*) &phyConf);
}[/code]
Thanks for your time.
EDIT:
Forgot to say that when I connect the ethernet cable ipconfig says that the IP is 169.254.68.247 and the subnet mask is 255.255.0.0 in case this extra info might help.