Ethernet Wiz W5500
Ethernet Wiz W5500
Hi All,
I've been playing with the W5500 click board using the example from libstock. I can see the code working as expected, however I want to server up html pages and am having problems working that out. Has anyone used this chip as a html server?
Cheers,
Paul
I've been playing with the W5500 click board using the example from libstock. I can see the code working as expected, however I want to server up html pages and am having problems working that out. Has anyone used this chip as a html server?
Cheers,
Paul
Re: Ethernet Wiz W5500
So a little more information. Using the eth wiz click example, the main code posted below I can get an echo back using a tcp terminal. When using a browser, I can see the sentsize = buffer size but nothing is rendered.
Could it be that the socket is getting closed or am I missing something.
With hundreds of views on this post in 24 hours surely someone out there has some ideas
Cheers
Paul
Could it be that the socket is getting closed or am I missing something.
With hundreds of views on this post in 24 hours surely someone out there has some ideas
Cheers
Paul
Code: Select all
* Project name:
ETH WIZ click board example
* Copyright:
(c) Mikroelektronika, 2015.
* Revision History:
20150514:
- initial release (FJ);
* Description:
This code demonstrates how to use ETH WIZ click board.
Board sends echo reply to UDP packets on "PORT_UDP" port.
Board listens to a connection request on "PORT_TCP" port. After connection is established, it sends echo reply to incoming TCP packets.
* Test configuration:
MCU: PIC18F45K22
http://ww1.microchip.com/downloads/en/DeviceDoc/41412F.pdf
Dev. Board: EasyPIC v7 Connectivity
http://www.mikroe.com/easypic/
Oscillator: HS-PLL 32.000 MHz, 8.000 MHz Crystal
Ext. modules: ETH WIZ click board - ac:ETH_WIZ_click
http://www.mikroe.com/click/eth-wiz/
SW: mikroC PRO for ARM
http://www.mikroe.com/mikroc/arm/
* NOTES:
- Place ETH WIZ click board in the mikroBUS socket 1.
- Put power supply jumper (J5) on the EasyPIC7 board in 3.3V position.
*/
#include "Wizchip_Conf.h"
#include "W5500.h"
#include "Socket.h"
// ETH WIZ click connections
sbit Wizchip_Rst at LATE1_bit;
sbit Wizchip_CS at LATE0_bit;
sbit Wizchip_Rst_Direction at TRISE1_bit;
sbit Wizchip_CS_Direction at TRISE0_bit;
// end of ETH WIZ click connections
// Socket & Port number definition
#define SOCK_ID_TCP 0
#define SOCK_ID_UDP 1
#define PORT_TCP 80
#define PORT_UDP 1000
#define DATA_BUF_SIZE 1024
uint8_t gDATABUF[DATA_BUF_SIZE];
volatile wiz_NetInfo gWIZNETINFO =
{
{0x00, 0x14, 0xA3, 0x72, 0x17, 0x3f}, // Source Mac Address
{10, 1, 1, 250}, // Source IP Address
{255, 255, 255, 0}, // Subnet Mask
{10, 1, 1, 1}, // Gateway IP Address
{10, 1, 1, 1}, // DNS server IP Address
NETINFO_STATIC
};
volatile wiz_PhyConf phyConf =
{
PHY_CONFBY_HW, // PHY_CONFBY_SW
PHY_MODE_MANUAL, // PHY_MODE_AUTONEGO
PHY_SPEED_10, // PHY_SPEED_100
PHY_DUPLEX_FULL, // PHY_DUPLEX_HALF
};
volatile wiz_NetInfo pnetinfo;
// brief Call back function for WIZCHIP select.
void CB_ChipSelect(void)
{
Wizchip_CS = 0;
}
// brief Call back function for WIZCHIP deselect.
void CB_ChipDeselect(void)
{
Wizchip_CS = 1;
}
// brief Callback function to read byte usig SPI.
uint8_t CB_SpiRead(void)
{
return SPI1_Read(0xAA);
}
// brief Callback function to write byte usig SPI.
void CB_SpiWrite(uint8_t wb)
{
SPI1_Write(wb);
}
// brief Handle TCP socket state.
void TCP_Server(void)
{
int32_t ret;
uint16_t size = 0, sentsize = 0;
unsigned char out_msg[20];
// Get status of socket
switch(getSn_SR(SOCK_ID_TCP))
{
// Connection established
case SOCK_ESTABLISHED :
{
// 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;
}
uart2_write_text("Data Received TCP\r\n");
// 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;
}
sprinti(out_msg, "Buff Size: %u\r\n", size);
uart2_write_text(out_msg);
sprinti(out_msg, "Sent Size: %u\r\n", sentsize);
uart2_write_text(out_msg);
}
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 :
{
// 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;
}
uart2_write_text("Data Received UDP\r\n");
// 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 };
Wizchip_Rst_Direction = 0; // Set Rst pin to be output
Wizchip_CS_Direction = 0; // Set CS pin to be output
CB_ChipDeselect(); // Deselect module
// Reset module
Wizchip_Rst = 0;
Delay_ms(1);
Wizchip_Rst = 1;
Delay_ms(1);
SPI1_Init_Advanced(_SPI_MASTER_OSC_DIV4, _SPI_DATA_SAMPLE_MIDDLE, _SPI_CLK_IDLE_LOW, _SPI_LOW_2_HIGH);
// Wizchip initialize
wizchip_init(buffsize, buffsize, 0, 0, CB_ChipSelect, CB_ChipDeselect, 0, 0, CB_SpiRead, CB_SpiWrite);
// Wizchip netconf
ctlnetwork(CN_SET_NETINFO, (void*) &gWIZNETINFO);
ctlwizchip(CW_SET_PHYCONF, (void*) &phyConf);
}
void main()
{
ANSELA = 0; // set PORTA as digital
ANSELB = 0; // set PORTB as digital
ANSELC = 0; // set PORTD as digital
ANSELD = 0; // set PORTA as digital
ANSELE = 0; // set PORTB as digital
SLRCON = 0;
W5500_Init();
wizchip_getnetinfo(&pnetinfo);
uart2_init(19200);
uart2_write_text("Ready\r\n");
while(1)
{
// TCP Server
TCP_Server();
// UDP Server
UDP_Server();
}
}
Re: Ethernet Wiz W5500
With 768 views, the lack of assistance is frustrating compared to what it was a couple of years back, especially from the Mikroe team.
Re: Ethernet Wiz W5500
Hi,
I apologize for the late reply, could you tell me which MCU are you using ?
Regards,
Filip.
I apologize for the late reply, could you tell me which MCU are you using ?
Regards,
Filip.
Re: Ethernet Wiz W5500
Hi Filip,
Thanks for the response.
I'm using the EasyPic V7 board with the 18F46K22 running at 20MHz. The WizNet W5500 click is in socket 1 as suggested. Using an app called "Multi Terminal" I can send and receive characters in TCP and UDP. I've included the zipped fileset which contains a few more files I've been playing with.
I need to be able to use an then integrate a small web server into my project for configuration of various settings, I tried the ENC28J60 but found the transmit buffer was way too small for my needs.
Cheers,
Paul
Thanks for the response.
I'm using the EasyPic V7 board with the 18F46K22 running at 20MHz. The WizNet W5500 click is in socket 1 as suggested. Using an app called "Multi Terminal" I can send and receive characters in TCP and UDP. I've included the zipped fileset which contains a few more files I've been playing with.
I need to be able to use an then integrate a small web server into my project for configuration of various settings, I tried the ENC28J60 but found the transmit buffer was way too small for my needs.
Cheers,
Paul
- Attachments
-
- ETH_WIZ_click.zip
- (372.33 KiB) Downloaded 213 times
Re: Ethernet Wiz W5500
Hi Filip,
Did you have any luck with the request.
Regards,
Paul
Did you have any luck with the request.
Regards,
Paul
Re: Ethernet Wiz W5500
Hi,
I didn't have success, so I will contact our developers to see if they have any idea.
Regards,
Filip.
I didn't have success, so I will contact our developers to see if they have any idea.
Regards,
Filip.
Re: Ethernet Wiz W5500
Hi,
Your help is much appreciated.
Kind Regards,
Paul
Your help is much appreciated.
Kind Regards,
Paul
Re: Ethernet Wiz W5500
Hi Filip,
Did you have any luck with the devs? I think most of the code is there, probably isn't a huge task to add the necessary bits.
Kind Regards,
Paul
Did you have any luck with the devs? I think most of the code is there, probably isn't a huge task to add the necessary bits.
Kind Regards,
Paul
Re: Ethernet Wiz W5500
Hi,
Well, since this request is rather custom code request (as you concluded that the click board is actually working, TCP and UDP),
I'm not in liberty to push our developers much, as there are task with higher priority at the moment.
Of course, I will update you when I have any information from them.
Regards,
Filip.
Well, since this request is rather custom code request (as you concluded that the click board is actually working, TCP and UDP),
I'm not in liberty to push our developers much, as there are task with higher priority at the moment.
Of course, I will update you when I have any information from them.
Regards,
Filip.
Re: Ethernet Wiz W5500
OK appreciate that, please note also that I'm happy to contribute to the development if that is an option. Otherwise I'll wait to hear back.
Cheers,
Paul
Cheers,
Paul
Re: Ethernet Wiz W5500
Hi,
Any news on this issue fro Mikroe as it is holding up my development work, or with the over 1600 views surely someone would have come across this issue and solved it.
Cheers,
Paul
Any news on this issue fro Mikroe as it is holding up my development work, or with the over 1600 views surely someone would have come across this issue and solved it.
Cheers,
Paul
Re: Ethernet Wiz W5500
Hi,
I've now managed the solve the issues and I can now server web pages correctly, redirect, etc.
Cheers,
Paul
I've now managed the solve the issues and I can now server web pages correctly, redirect, etc.
Cheers,
Paul
Re: Ethernet Wiz W5500
Hi,
I'm glad that you managed to solve this.
Can you please post the solution here, so that other user can get this working ?
Thanks in advance.
Regards,
Filip.
I'm glad that you managed to solve this.
Can you please post the solution here, so that other user can get this working ?
Thanks in advance.
Regards,
Filip.
Re: Ethernet Wiz W5500
Considering I paid for the development when Mikroe were too busy to look at their halfway coded solution I'd be happy to share what is a comprehensive solution in exchange for an STM32 dev board.
Cheers,
Paul
Cheers,
Paul