2014年5月18日星期日

[Help] W5300 UDP does not receive data

dsp control W5300 send and receive data using UDP and PC . UDP send W5300 's no problem, but can not receive UDP packets coming from PC . Code is as follows .
In CCS4.2 in debugging , rxlen ( receive buffer receives characters in length ) is always 0 for normal continuous operation ;
If "rxlen = 0x0fff & getSn_RX_RSR (s);" before adding breakpoints , rxlen are receiving value , and also to receive the correct number of characters .
simply is :
dsp continuous operation , getSn_SSR (s) return 0 ;
dsp single-step operation , getSn_SSR (s) have a return value.
What is the reason , heroes to the analysis .

socket (s, Sn_MR_UDP, port, mode);
switch ((0x00ff & getSn_SSR (s)))
{
case SOCK_UDP:
rxlen = 0x0fff & getSn_RX_RSR (s);
if (rxlen> 0)
{
rxlen = recvfrom (s, (uint8 *) rxbuf, rxlen, gw, & rxport);
}
if (len! = sendto (s, p, len, gw, port)) / / send the data to the ; destination
{}
break;
...........
}
------ Solution ----------------------------------- ---------
your getSn_SSR () function in what is called the frequency of a ?
receiving mode is polled or interrupt ?
------ Solution ---------------------------------------- ----
is said to add a breakpoint pause, and then continue on the right ? Then you can add a delay here is not the chip slow response
------ For reference only ---------------------- -----------------
no firewall , PC ping W5300 is through the
------ For reference only - --------------------------------------
back upstairs ,
getSn_SSR () is polling mode , a second call once.

look w5300 manuals UDP receiver interrupt mode is not recommended , and the official example is polling , so with the polling.
udp receiving a query getSn_RX_RSR (7) of this function . The return value indicates the number of data bytes received
strange place : This function returns the value set breakpoints only . No break , the return value has been zero.
------ For reference only -------------------------------------- -
rxlen = 0x0fff & getSn_RX_RSR (s); sentence plus a breakpoint , it stops ---- > click on the Send button in the PC program - -> dsp continue to perform at the breakpoint ; rxlen this mode of operation has a return value, and this value is exactly equal to the number of bytes sent pc + UDP header length. ( But not removing the content may be aligned or size of client )

without breakpoints, the normal procedure when performed continuously dsp , pc sending , rxlen always return 0 ;

chip , then slow to such a degree should not be slow Oh ? ! And PC sends random , dsp polling plus delay, inefficiency.

interrupt the trial , it seems not enter interrupt , depressed ~ ~
------ For reference only --------------------- ------------------

you now look into the problem , and then after considering how to solve . When
continuous execution Rxlen later reassigned , ah , first distinguish which calls return 0
------ For reference only ---------------- -----------------------
rxlen = 0x0fff & getSn_RX_RSR (s); continuous execution is here return 0
query read registers frequent crashes, will be the reason for the word length of it?
use interrupt mode , the effect is better.

Thank you discuss !

没有评论:

发表评论