W5500 Not responding for the SPI_Read

Hi

I am using PIC18f4520 to implement the webserver along with w5500. I have jsut checked the SPI communication between both of them writing part is ok , while reading the same register i am zeros always.

Here is my code:

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;


void CB_ChipSelect(void)
{
    Wizchip_CS = 0;
}

// brief Call back function for WIZCHIP deselect.
void CB_ChipDeselect(void)
{
    Wizchip_CS = 1;
}

uint8_t shar;
void main() {
       SPI1_Init();

       TRISC.B6 = 0;
       TRISC.B7 = 1;
       
       Wizchip_CS_Direction = 0;
       Wizchip_Rst_Direction = 0;
       
       Wizchip_Rst = 1   ;

       UART1_Init(4800);
       CB_ChipSelect();
       SPI1_Write(0x00);
       SPI1_Write(0x09);
       SPI1_Write(0x01);
       SPI1_Write(0x10);
       CB_ChipDeselect();
       
       while(1){
//             UART_Write_Text("Hello123 !");
                CB_ChipSelect();
                SPI1_Write(0x00);
                SPI1_Write(0x09);
                SPI1_Write(0x05);
                shar = SPI1_Read(0);
                UART_Write(shar);
                CB_ChipDeselect();
                Delay_ms(100);
//             UART_Write_Text("Hello !");
       }
}

Thanks much,
Dhanunjay

    CB_ChipSelect();
    SPI1_Write(0x00);
    SPI1_Write(0x09);
    SPI1_Write(0x01);
    SPI1_Write(0x10);
    CB_ChipDeselect();

With this block you instruct W5500 to give information from reg #9 in common register block (SHAR0). Address=0x0009, OPmode=1 (fixed length 1), operation=read, block select=0.

            CB_ChipSelect();
            SPI1_Write(0x00);
            SPI1_Write(0x09);
            SPI1_Write(0x05);
            shar = SPI1_Read(0);
            UART_Write(shar);
            CB_ChipDeselect();

with this block you instruct W5500 to write data to register #9. Address=0x0009, block select=0, operation=write, fixed length 1 mode.

So you seem confused read and write operations, and that’s why you get 0x00 in return (for SPI write command).

1 Like

Hi.

@Eugeny already explained to you well.

What you are currently trying to read is SHAR.
It is normal for the 0x00 (reset value) to be read because you have never entered a value in this register in your code.

In the data sheet below, it is helpful if you look at the Address phase and the Control phase, and the reset value of each address.

http://wizwiki.net/wiki/lib/exe/fetch.php?media=products:w5500:w5500_ds_v108e.pdf

1 Like