Hello friends, I am having issues with my TCP server on a W5500. My SN_SR register always stays at 0x00 and the Sn_CR register never clears. I am able to ping the device on the network and SPI seems to be working correctly. I have written the following snippet of code in order to test the Sn_SR register:
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.
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.
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.
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
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
because bsb is 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.