TX/RX NOT WORKING IN UDP MODE FOR W5300
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Ethernet Chips
No replies yet. Be the first to reply.
Join the discussion.
Share projects and connect with makers.
Joined before the site update? first.
New to WIZnet Makers?
We sent a verification link to your address. Open it to activate your account, then log in.
Accounts from this email provider are reviewed by an administrator after verification. Approval usually takes one business day.
Already have an account?
Enter your email address. If it belongs to an account, we'll send a link to set a new password. Members who joined before the site update use this to set their password.
If an account uses that address, we sent a link to set a new password. The link works once and expires in 30 minutes.
Know your password?
Need an account?
RE: TX/RX NOT WORKING IN UDP MODE FOR W5300
by irina WIZnet ·
I don’t think you can solve the problem right now with your explanation.
First, please review the iolibrary we provided.
After sending the send/recv command, you have to wait until it is cleared.
RE: TX/RX NOT WORKING IN UDP MODE FOR W5300
by shijesh ·
Hi there,
Thanks for replying.
I am using the hercules utility from PC to transmit few(<10) bytes to w5300. but the Sn_RX_RSR register is not showing the correct length of the data received & keeps changing even when the data is stopped.
I have verified from wireshark that data is getting transmitted to W5300.
why is this happening kindly explain???
I will send u the copy of my entire code .
Regards
shijesh
RE: TX/RX NOT WORKING IN UDP MODE FOR W5300
by shijesh ·
Here is my code which Iam using. kindly go through the same.
Main()
{
uint16 data_buf = (uint16) 0xC000; // buffer for loopback data
wiz_sysinit ();
while (1)
{
loopback_udp (7, 200,data_buf, 0); // using socket 7
}
}
INSIDE MAIN FN I am calling this
Wiznet intialisation
void wiz_sysinit (void)
{
//----------WIZNET 5300 CONFIGURATION SECTION -----------------------//
*(vuint16 *)TMSR0 = 0x08; // TX MEM SIZE EACH SOCKET
*(vuint16 *)TMSR1 = 0x08;
*(vuint16 *)TMSR2 = 0x08;
*(vuint16 *)TMSR3 = 0x08;
*(vuint16 *)TMSR4 = 0x08;
*(vuint16 *)TMSR5 = 0x08;
*(vuint16 *)TMSR6 = 0x08;
*(vuint16 *)TMSR7 = 0x08;
*(vuint16 *)RMSR0 = 0x08; // RX MEM SIZE EACH SOCKET
*(vuint16 *)RMSR1 = 0x08;
*(vuint16 *)RMSR2 = 0x08;
*(vuint16 *)RMSR3 = 0x08;
*(vuint16 *)RMSR4 = 0x08;
*(vuint16 *)RMSR5 = 0x08;
*(vuint16 *)RMSR6 = 0x08;
*(vuint16 *)RMSR7 = 0x08;
*(vuint16 *)RTR0 = 0x0F; // Retransmission time out , 400ms
*(vuint16 *)RTR1 = 0x0A;
}
/******** UDP loopback program*****/
{
}
Function definitions for the above functions are given below
uint8 getSn_SSR(SOCKET s)
{
uint8 ssr, ssr1;
ssr = (uint8)IINCHIP_READ(Sn_SSR1(s)) & 0x00FF; // first read
while(1)
{
ssr1 = (uint8)IINCHIP_READ(Sn_SSR1(s))& 0x00FF; // second read
if(ssr == ssr1)
{
break; // if first == second, Sn_SSR value is valid.
}
ssr = ssr1; // if first <> second,
}
return ssr;
}
uint32 getSn_RX_RSR(SOCKET s)
{
uint32 received_rx_size=0;
uint32 received_rx_size1=1;
uint32 a=0,b=0,c=0,d=0;
uint32 e=0,f=0,g=0;
e = IINCHIP_READ(Sn_RX_RSR0(s));
a = (e<<24);
f = IINCHIP_READ(Sn_RX_RSR1(s));
b = (f<<16);
g = IINCHIP_READ(Sn_RX_RSR2(s));
c = (g<<8);
d = IINCHIP_READ(Sn_RX_RSR3(s));
while(1)
{
received_rx_size = ((b & 0x00FF0000) | (c & 0x0000FF00) | (d & 0x000000FF));
}
return received_rx_size;
}
uint16 IINCHIP_READ(uint32 addr)
{
return *(vuint16 *)addr;
}
uint8 socket(SOCKET s, uint8 protocol, uint16 port, uint16 flag)
{
IINCHIP_WRITE(Sn_MR1(s),(uint16)(protocol | flag));
IINCHIP_WRITE(Sn_PORTR1(s),port); //
setSn_CR(s, Sn_CR_OPEN); // open s-th SOCKET
check_sendok_flag[s] = 1; // initialize the sendok flag.
return 1;
}
void IINCHIP_WRITE(uint32 addr,uint16 data)
{
*(vuint16 *)addr = data;
}
void setSn_CR(SOCKET s, uint16 com)
{
IINCHIP_WRITE(Sn_CR1(s),com); //
while(IINCHIP_READ(Sn_CR1(s))); // wait until Sn_CR is cleared.
}
void close_socket(SOCKET s)
{
setSn_IR(s ,0x00FF); // Clear the remained interrupt bits.
setSn_CR(s ,Sn_CR_CLOSE); // Close s-th SOCKET
}
uint8 getSn_IR(SOCKET s)
{
}
uint32 sendto(SOCKET s, uint16 * buf, uint32 len, uint16 * addr, uint16 port)
{
uint16 status=0;
uint16 isr=0;
uint32 ret=0;
if (len > getIINCHIP_TxMAX(s)) // check size not to exceed MAX size.
ret = getIINCHIP_TxMAX(s);
else
ret = len;
IINCHIP_WRITE(Sn_DIPR0(s),192); // 192
IINCHIP_WRITE(Sn_DIPR1(s),168); // 168
IINCHIP_WRITE(Sn_DIPR2(s),0); // 0
IINCHIP_WRITE(Sn_DIPR3(s),10); // 10
IINCHIP_WRITE(Sn_DPORTR1(s),100); // 100
while (!((isr = getSn_IR(s)) & Sn_IR_SENDOK))// wait SEND command
{
status = getSn_SSR(s)
}
setSn_IR(s, Sn_IR_SENDOK); // Clear Sn_IR_SENDOK
return ret;
}
uint32 wiz_write_buf(SOCKET s,uint8* buf,uint32 len)
{
uint32 k=0;
uint32 r_val;
uint32 r_val1;
}
void setSn_TX_WRSR(SOCKET s, uint32 size)
{
IINCHIP_WRITE(Sn_TX_WRSR0(s), (uint16)(size >> 24));
IINCHIP_WRITE(Sn_TX_WRSR1(s), (uint16)(size >> 16));
IINCHIP_WRITE(Sn_TX_WRSR2(s), (uint16)(size >> 8)) ;
IINCHIP_WRITE(Sn_TX_WRSR3(s), (uint16)size);
}
uint32 recvfrom(SOCKET s, uint16 * buf, uint32 len, uint16 * addr, uint16 *port)
{
uint16 head[10];
uint32 data_len=0;
if ( len > 0 )
{
switch (IINCHIP_READ(Sn_MR1(s)) & 0x07)
{
case Sn_MR_UDP : // UDP mode
wiz_read_buf(s, (uint8*)head, 8);
}
return data_len;
}
uint32 wiz_read_buf(SOCKET s, uint8* buf,uint32 len)
{
uint32 k;
if (len%2==0) // length is even number
{
len = len/2 ;
}
else
{
len = (len +1)/2 ;
}