W5500 Sn_SR always stays 0x00, Sn_CR never clears
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: W5500 Sn_SR always stays 0x00, Sn_CR never clears
by Eugeny ·
Socket closed
You do not test for it in the code provided
You must ensure you do preparations properly. You reset the chip using RESET pin per specification, and optionally perform software reset using MR. I am not 100% sure if that may be the case, but you should set basic properties for the networking communication like MAC address.
This is the second thing to prove after you ensure proper reset by reading VERSIONR register. If SPI does not work as expected, you may simply read/write to wrong locations within the chip causing undefined behavior.
RE: RE: W5500 Sn_SR always stays 0x00, Sn_CR never clears
by Mobius1 ·
Thank you for your response. I apologize for failing to provide some information as I am new to the embedded world. I have now done a reset at the start of the program my version register reads 0x04.

This is should be setting the socket registers
setSn_MR(sn, Sn_MR_TCP);
setSn_PORT(sn, 5000);
setSn_CR(sn, Sn_CR_OPEN);
delay_ms(5000);
printf(“\r\nTHIS IS VALUE OF Sn_MR: %02X\r\n”, getSn_MR(sn));
printf(“\r\nVALUE OF Sn_CR: 0x%02X\r\n”, getSn_CR(sn));
printf(“\r\nVALUE OF Sn_SR: 0x%02X\r\n”, getSn_SR(sn));
This is how it is actual behaving

This is how it reads once it enters the loop to evaluate if Sn_SR is set to SOCK_INIT

SPI should be working as I am able to write network configs to the proper registers.

One thing of note is I can write all the needed registers except for 0x0010 that is needed for the IP. I’m assume this could be a part of my problem.
Thank you for the help, I apologize if anything is unclear.
RE: W5500 Sn_SR always stays 0x00, Sn_CR never clears
by Eugeny ·
Byte order is confused for address. Hopefully mistake is in printf.
Now compare address for Sn_CR in the datasheet with the address your program displays. If byte order is confused, you are trying to read location 0xa800, then 0xa801 etc. and of course you get garbage. You must provide chip with address and BSB/RWB/OM information before you can access the register.
If 0xa8 is control byte, then you address “Socket 2 TX Buffer” space.
RE: W5500 Sn_SR always stays 0x00, Sn_CR never clears
by Mobius1 ·
uint8_t WIZCHIP_READ(uint32_t AddrSel) {
uint8_t spi_data[4];
uint8_t spi_rData[4];
printf(“\r\nWIZCHIP_READ: Entering function with address 0x%04X\r\n”, AddrSel);
spi_data[0] = (AddrSel & 0x00FF0000) >> 16;
spi_data[1] = (AddrSel & 0x0000FF00) >> 8;
spi_data[2] = ((make8(AddrSel, 0) & 0x1F) << 3) | 0x00;
spi_data[3] = 0x00;
}
void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t data) {
uint8_t spi_data[4];
}
This is what my read and write functions look like
RE: RE: W5500 Sn_SR always stays 0x00, Sn_CR never clears
by Eugeny ·
Display SPI data instead of address in the debug and see if it matches the location/operation you assume it performs.
RE: W5500 Sn_SR always stays 0x00, Sn_CR never clears
by Mobius1 ·
Yeah my SPI data is complete junk. I’m not sure how I should go about writing a read and write function that accomplishes targeting the socket registers. The ioLibary code doesnt seem to be working correctly. It seems like the control byte is off.
WIZCHIP_SOCKET_WRITE(0x5000, 0x01);
to write 0x01 to socket register 5
ADDRESS HIGH BYTE: 00
ADDRESS LOW BYTE: 50
CONTROL BYTE: 04
WRITTEN BYTE: 01
RE: W5500 Sn_SR always stays 0x00, Sn_CR never clears
by Eugeny ·
to write 0x01 to socket 3 register 5
WIZCHIP_SOCKET_WRITE(0x500 | (0x0d << 3), 0x01);or
WIZCHIP_SOCKET_WRITE((chip_address << 8) | (bsb << 3), 0x01);RE: W5500 Sn_SR always stays 0x00, Sn_CR never clears
by Mobius1 ·
This seems to be working ok for the write function, however read seems to be off. First set is write the second is read. I appreciate your help.
ADDRESS HIGH BYTE: 00
ADDRESS LOW BYTE: 05
CONTROL BYTE: 6C
WRITTEN BYTE: 01
ADDRESS HIGH BYTE: 00
ADDRESS LOW BYTE: 00
CONTROL BYTE: 68
THIS IS THE VALUE OF SOCKET 5: 03
RE: W5500 Sn_SR always stays 0x00, Sn_CR never clears
by Eugeny ·
I was wrong
because
bsbis already <<3 in the functions. What we are doing now is not related to W5500, but relates to just C and code of the functions you currently have. Your task is providing address, bsb and data into there in proper format. Note you must use appropriate address and bsb per datasheet’s chapter 3 to address specific data.