WIZnet Developer Forum

Stuck in "sendto"

Dear Sir/Miss

I am trying to get a W5500 running with your stack. I can see on Wireshark that a DHCP lease request goes out successfully. It all looks like it should etc. The issue is that my code gets stuck in the function “sendto”. In particular…

while(1)
{
tmp = getSn_IR(sn); Always returns 0, hence the stuck in the loop
if(tmp & Sn_IR_SENDOK)
{
setSn_IR(sn, Sn_IR_SENDOK);
break;
}
//M:20131104
//else if(tmp & Sn_IR_TIMEOUT) return SOCKERR_TIMEOUT;
else if(tmp & Sn_IR_TIMEOUT)
{
setSn_IR(sn, Sn_IR_TIMEOUT);
//M20150409 : Fixed the lost of sign bits by type casting.
//len = (uint16_t)SOCKERR_TIMEOUT;
//break;
#if WIZCHIP < 5500 //M20150401 : for WIZCHIP Errata #4, #5 (ARP errata)
if(taddr) setSUBR((uint8_t*)&taddr);
#endif
return SOCKERR_TIMEOUT;
}
////////////
}

From what I can tell it never sees the packet finish sending so keeps on waiting. I think its an interrupt issue. I think that the IMR bits are never set/cleared in the code. I’m new to Wiznet but its my understanding that they must be in order to see the interrupt. Though if that’s the case I don’t understand how the code works.

Also, I don’t think the INT pin on the W5500 is being used? It certainly doesn’t do anything in my code. Is this an error?

Kind regards

Hi,
from what you say packet transmission is made but the DHCP server then does not recognize the content.
What MPU uses? Maybe a 16 or 32 bit CPU?
If this is the case then DHCP packet sended is malformed ([url]Problems while compiling dhcp.c file]).
Some 16/32 bits compilers warn when they are operating an optimization (on structures) while others ignore it, but the structure is no longer serialized in right mode and bytes are not placed as they should be.

Hi Coccoliso

Thank you very much for taking the time to look over and reply. Im sorry to say that tried to include everything but forgot to mention that the server does give out a lease, again sorry. I’m using a 32bit Microchip CPU, with there default compliers, C32.

I’m practically certain the issue is related to the interrupt flags. It seems to never see the end of the packet going out. That why it gets stuck in the loop in “sendto”. Therefore I don’t think it even looks for a response, its still waiting for the packet to leave the device.

Though from looking through your link, it may well be the same symptom as the other issue. Perhaps the INT flags aren’t set correctly due to this. Though I can’t see were in the code the IMR registers are even called (I think they need to be set/cleared?)

Another question would be do you have a working DHCP project on a 32 bit processor?

Kind regards
Wizneter

Hi,
one thing that comes in mind is the correct setting of the SPI.
With PIC to obtain a correct reading I had to set the SPI in this way: clock idle low, rising edge and sample on end.
With routines that uses can correctly read a register ( ex product id) or not?
For what it regards as a 32-bit C DHCP I can not help you.
I ported the wiznet routines (driver / DHCP / DNS and PING) in firewing basic for PIC18 (8-bit) and PIC24 (16-bit) devices so sources are written in basic. The firewing compiler use the microchip C compiler to get the HEX file and so the structures are optimized with PIC24 and PIC32 devices.
You can not send the structure “as is” but you have to decompose it in bytes before sending … the problems that I have mentioned in previous post.
I do not know if can help you but basic sources are here http://www.firewing.info/pmwiki.php?n=FirewingUser.W5500.

Hi Coccoliso

Thank you I’ve got it going.

Once I fixed up the structures the “sendto” function didn’t lockup and DHCP started to wiork.

Thanks for all your help.

Kind regards
Wizneter

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.