W5100 Listen issue
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: W5100 Listen issue
by hjjeon0608 ·
Hi, Omer.
I want to know your code.
Please, post code.
How to set mode register, command and etc.
And I recommend to use reference code at WIZnet.
Best regards.
RE: W5100 Listen issue
by Omer ·
Hi,
I have attached the code files.
Please review them and let me know what I am missing.
I have done the following configurations:
Thanks!!!
wiznet_tcp.c (10.8 KB)
wiznet.h (11.3 KB)
wiznet.c (43.2 KB)
RE: W5100 Listen issue
by hjjeon0608 ·
Hi, Omer.
I think your code is correct.
So, I want to know your main functions.
And I found strange code.
uint8_t listen(SOCKET s) { uint8_t ucharStatus; ucharStatus = getSn_SR(0); if (ucharStatus == SOCK_INIT) { write_wiznet_reg(Sn_CR(s),Sn_CR_LISTEN); /* wait to process the command... */ while( read_wiznet_reg(Sn_CR(s)) ); /* ------- */ ucharStatus = getSn_SR(0); if(ucharStatus == SOCK_LISTEN) { ucharStatus = 0; } else { close(s); ucharStatus = 1; } } else { close(s); ucharStatus = 1; } return ucharStatus; }You use socket number together ‘0’ and ‘s’.
So, please check whether it causes problem.
Best regards.
RE: W5100 Listen issue
by Omer ·
Hi,
I am calling the below function from main:
uint32_t initWiznet(void)
{
//unsigned char MAC_ADDR[6];
uint8_t status = 0x01;
/* Power the wiznet chip /
GPIO_PinOutSet (gpioPortC, 1);
Delay_ms(1);
/ Reset the wiznet chip */
ASSERT_WIZNET_RESET();
Delay_ms(1);
init_usart0_for_wiznet();
DEASSERT_WIZNET_RESET();
setRTR(6000); /* Retry time = 600 ms*/
Delay_ms(1);
setRCR(3); /* Retry count = 3 /
Delay_ms(1);
//setIMR(0x00); / Interrupt mask */
setGAR(); /* Gateway IP address /
Delay_ms(1);
setSUBR(); / Subnet mask /
Delay_ms(1);
setSHAR(); / MAC address /
Delay_ms(1);
setSIPR(); / Source IP address */
Delay_ms(1);
SysInit(0x55, 0x55); /* TX = 8kB, RX = 8 kB /
Delay_ms(1);
setIMR(IR_SOCK(0)); / Enable the socket 0 interrupt */
Delay_ms(1);
/* Configure the EFM32 for external interrupt from Wiznet chip */
NVIC_ClearPendingIRQ(GPIO_ODD_IRQn);
NVIC_EnableIRQ(GPIO_ODD_IRQn);
/* Configure PE13 as input /
GPIO_PinModeSet(gpioPortE, 13, gpioModeInput, 1);
/ Set falling edge interrupt */
GPIO_IntConfig(gpioPortE, 13, false, true, true);
write_wiznet_reg(Sn_IR(0), 0xff);
/* Open the socket for server mode /
temp = 1;
/ The below code is for testing purpose only
/
while( temp)
{
socket(0, Sn_MR_TCP, 80, 0x00);
temp = getSn_SR(0);
temp = listen(0);
}
/ Refer to GPIO_ODD_IRQHandler() for further packet processing
*/
return status;
}
I am trying to connect to socket 0.
RE: W5100 Listen issue
by Omer ·
Hi,
If my code looks Ok, then how can I debug this issues?
Do I need to check something on my desktop side?
If yes then how?
Are there any tools which can help in debugging this issues?
RE: W5100 Listen issue
by hjjeon0608 ·
Hi, Omer.
I wonder one point.
If your MCU is so fast, listen command could be done before SOCK_INIT status changed.
SOCK_CLOSED ------changing -------> SOCK_INIT
|
(listen command here)
So, I recommend to use case(1) or debug with changing return value(2).
switch(getSn_SR(s)) // check SOCKET status { // ------------ case SOCK_ESTABLISHED: // ESTABLISHED? if(getSn_IR(s) & Sn_IR_CON) // check Sn_IR_CON bit { printf("%d : Connect OK\r\n",s); setSn_IR(s,Sn_IR_CON); // clear Sn_IR_CON } if((len=getSn_RX_RSR(s)) > 0) // check the size of received data { len = recv(s,buf,len); // recv if(len !=send(s,buf,len)) // send { printf("%d : Send Fail.len=%d\r\n",s,len); } } break; // --------------- case SOCK_CLOSE_WAIT: // PASSIVE CLOSED disconnect(s); // disconnect break; // -------------- case SOCK_CLOSED: // CLOSED close(s); // close the SOCKET socket(s,Sn_MR_TCP,port,mode); // open the SOCKET break; // ------------------------------ case SOCK_INIT: // The SOCKET opened with TCP mode listen(s); // listen to any connection request from "TCP CLIENT" printf("%d : LOOPBACK_TCPS(%d) Started.\r\n",s,port); break; default: break; }i.e. check status is SOCK_INIT then command listen.
Try and then reply again please.
Best regards.
RE: W5100 Listen issue
by Omer ·
Hi,
Thanks for your replies.
The issues did seem to be with the delay.
I added delay in the wiznet read function and made it same like the wiznet write function.
The issue is resolved now.
Thanks once again for your help!
RE: W5100 Listen issue
by Leytronix ·
Hi Omer,
At the moment I am running into exactly the same issue with the W5100. I understand you solved it with a delay in the read function? I do not understand where that is since the W5100 first has to go into LISTEN mode before anything can be read…
Can you explain that?
Thanks,
Tjerk
RE: RE: W5100 Listen issue
by irina WIZnet ·
In the example above, a delay of 10ms was added after the chip reset.