Hi everyone, me need help. I trying write DHCP client for gathering IP address but i can’t open socket in UDP mode (as in any other mode). My steps (between steps has delay ~300ms):
- Connect Ethernet cable and power up;
- Hardware reset using RST pin – OK;
- Read Chip ID register and check value (0x04) – OK;
- Software reset by write value 0x80 to Mode Register – OK;
- Wait until RST bit is reset – OK;
- Check PHYCFGR register value - get 0xBF, link UP – OK (may be);
- Write 0x0044 value to S0_PORT register – OK;
- Read value from S0_PORT register and compare with written value (0x0044) – OK;
- Write 0x02 value to S0_MR for UDP mode – OK;
- Read value from S0_MR register and compare with written value (0x02) – OK;
- Write 0x01 value to S0_CR for open socket – OK;
- Read value from S0_CR register and compare with 0x00 (command accepted) – OK;
- Read value from S0_SR – always read 0x00. Why?
I tried this steps for all sockets – can’t open no one. I write to registers using 1MHz SPI speed in SPI_MODE0 (MSB first) and Variable Length Data Mode. I tried using Fixed Lingth Data Mode – without changes. I don’t use some library – only direct write to registers using simple SPI driver.
Also i tried setup static IP address (gateway, mask, source IP) and using ping tool for check W5500 working. W5500 answer on ping requests.
Also i noticed strange behavior with RST bit in PHYCFGR register. After write RST bit to 0 it is not never set to 1, LEDs on Ethernet connector is disabled. After write RST bit to 1 using SPI – LEDs on Ethernet connector is blinks. It is nornaly?
Please, help me. I don’t have no idia :(. I have two W5500 and both don’t work.