WIZnet Developer Forum

Do not init network

I have dealt with the w5500 and it worked.
But faced with the w5100. Microcontroller stm32f100.
Link is a good (led flash), reset OK. But it is not initialized network attributes.
All I tried. What is the problem?

#define WIZNET_WRITE_OPCODE 0xF0
#define WIZNET_READ_OPCODE 0x0F
//Wiznet W5100 Reg Addr
#define MR 0x0000 // Mode Register
#define GAR 0x0001 // Gateway Address: 0x0001 to 0x0004
#define SUBR 0x0005 // Subnet mask Address: 0x0005 to 0x0008
#define SAR 0x0009 // Source Hardware Address (MAC): 0x0009 to 0x000E
#define SIPR 0x000F // Source IP Address: 0x000F to 0x0012
#define RMSR 0x001A // RX Memory Size Register
#define TMSR 0x001B // TX Memory Size Register

void SPI_Write(uint16_t addr, uint8_t data)
{
// Activate the CS pin
wizchip_select();
// Start Wiznet W5100 Write OpCode transmission
wizchip_write(WIZNET_WRITE_OPCODE);
// Start Wiznet W5100 Address High Bytes transmission
wizchip_write((uint8_t)((addr & 0xFF00) >> 8));
// Start Wiznet W5100 Address Low Bytes transmission
wizchip_write((uint8_t)(addr & 0x00FF));
// Start Data transmission
wizchip_write(data);
// CS pin is not active
wizchip_deselect();
}
uint8_t SPI_Read(uint16_t addr)
{ uint8_t r;
// Activate the CS pin
wizchip_select();
// Start Wiznet W5100 Read OpCode transmission
wizchip_write(WIZNET_READ_OPCODE);
// Start Wiznet W5100 Address High Bytes transmission
wizchip_write((uint8_t)((addr & 0xFF00) >> 8) );
// Start Wiznet W5100 Address Low Bytes transmission
wizchip_write((uint8_t)(addr & 0x00FF));
//Read data
r = wizchip_read();
// CS pin is not active
wizchip_deselect();
return®;
}
void W5100_Init()
{ uint32_t i ;
// Ethernet Setup
uint8_t mac_addr[6] = {0x02,0x16,0x36,0xDE,0x58,0xF6};
uint8_t ip_addr[4] = {192,168,1,2};
uint8_t sub_mask[4] = {255,255,255,0};
uint8_t gtw_addr[4] = {192,168,1,1};
// Setting the Wiznet W5100 Mode Register: 0x80
SPI_Write(MR,0x80); // MR = 0b10000000;
for (i=0xFFFFF;i!=0;i–); // the delay after reset chip

SPI_Write(GAR + 0,gtw_addr[0]);
SPI_Write(GAR + 1,gtw_addr[1]);
SPI_Write(GAR + 2,gtw_addr[2]);
SPI_Write(GAR + 3,gtw_addr[3]);

SPI_Write(SAR + 0,mac_addr[0]);
SPI_Write(SAR + 1,mac_addr[1]);
SPI_Write(SAR + 2,mac_addr[2]);
SPI_Write(SAR + 3,mac_addr[3]);
SPI_Write(SAR + 4,mac_addr[4]);
SPI_Write(SAR + 5,mac_addr[5]);

SPI_Write(SUBR + 0,sub_mask[0]);
SPI_Write(SUBR + 1,sub_mask[1]);
SPI_Write(SUBR + 2,sub_mask[2]);
SPI_Write(SUBR + 3,sub_mask[3]);

SPI_Write(SIPR + 0,ip_addr[0]);
SPI_Write(SIPR + 1,ip_addr[1]);
SPI_Write(SIPR + 2,ip_addr[2]);
SPI_Write(SIPR + 3,ip_addr[3]);
// Setting the Wiznet W5100 RX and TX
SPI_Write(RMSR,0x55);
SPI_Write(TMSR,0x55);
}

1 Like

How did you know it? Why do you think “network attrubites” are not initialized?
Please explain your issue.

I understood not read registers. But why?
Working procedures for 5500:
uint8_t wizchip_read()
{ uint8_t rb;
while (!(SPI1 -> SR & SPI_SR_TXE)); //check buffer
SPI1 -> DR = 0xFF ; // transfer
while (!(SPI1->SR & SPI_SR_RXNE)); // wait input
rb = SPI1 -> DR ;
return rb;
}

void wizchip_write(uint8_t wb)
{ uint8_t rb;
while (!(SPI1 -> SR & SPI_SR_TXE)); //wait buffer
SPI1 -> DR = wb ; // byte to line
while (!(SPI1->SR & SPI_SR_RXNE)); // wait input
rb = SPI1 -> DR ;
}
For 5100 it does not work. Can faulty “hardware”?

What is the actual circuit diagram of your module?

Files attached
2.pdf (108 KB)
1.pdf (52.3 KB)

Circuit seems to be ok. I propose using scope or logical analyzer to see what is going on with SPI bus and there’re no issues with it (for example, 16 bit communication instead of 8-bit communication).

Copyright © 2017 WIZnet Co., Ltd. All Rights Reserved.