Properly resetting the W5100 during propeller reboot??
Hi, i was wondering if anyone knew the proper way to "reset" the W5100??
i am using "W5100.spin" for control and the "W5100.spin" module imports "Spi5100CounterPasm.spin"
my top level sets up the W5100 using DHCP, but sometimes when connections are lost, after trying a few other things i command the propeller to Reboot.
on power on the propeller executes the command:
wiz.HardReset(WIZ_RESET)
where "WIZ_RESET" == 14.
but for some reason the device will not accept an ip and will keep trying forever untill the actual power to the w5100 is cycled, this tells me there is a register somewhere i am not clearing or initializing correctly.
could someone please help me to understand what i need to clear in order for the device to be configurable by DHCP after the Prop reboots??
Cheers!
i am using "W5100.spin" for control and the "W5100.spin" module imports "Spi5100CounterPasm.spin"
my top level sets up the W5100 using DHCP, but sometimes when connections are lost, after trying a few other things i command the propeller to Reboot.
on power on the propeller executes the command:
wiz.HardReset(WIZ_RESET)
where "WIZ_RESET" == 14.
but for some reason the device will not accept an ip and will keep trying forever untill the actual power to the w5100 is cycled, this tells me there is a register somewhere i am not clearing or initializing correctly.
could someone please help me to understand what i need to clear in order for the device to be configurable by DHCP after the Prop reboots??
Cheers!

Comments
Also, post your code.
one thing i do notice, if i rest my finger on top of the W5100 while its trying to acquire an ip address its seems to be slightly hotter than when its actually connected and communicating. maybe theres a thermal issue caused from some kind of heavy looping somewhere???
regardless, heres the source:
(if you are going to run this code, be sure to put it into simulation mode or it will block where it tries to read in serial data)
CON _clkmode = xtal1 + pll16x _xinfreq = 5_000_000 SimMode = True 'Propeller Will Run In Simulation Mode And Try To Send Data To The Server, Data is the String From "SimulationString" DAT 'MODULE CONFIGURATION MAC_ADDRESS byte $00, $08, $DF, $16, $50, $52 Module_Name byte "A3_Module", 0 'NEVER USE SPACES!!! :( SEND_PORT word 5052 RECV_PORT word 6062 'SERVER DESTINATION ADDRESS Server_IP byte 192, 168, 13, 38 'Use this for Simulation Mode Only!! to use comment out the code behinde the comment: " 'DATA FROM SERIAL!!!!!!!!!!!!! " and uncomment the line with this variable in it SimulationString byte "&IR=1&CS=14&FE=45&HM=16&DP=27&" CON 'USER SETUP CON BUFFER_2K = $800 CR = $0D LF = $0A SOH = $01 #0, CLOSED, TCP, UDP, IPRAW, MACRAW, PPPOE DHCP_ATTEMPTS = 5 DISCONNECT_ATTEMPTS = 5 USB_Rx = 31 USB_Tx = 30 { Spinneret PIN IO } SPI_MISO = 0 ' SPI master in serial out from slave SPI_MOSI = 1 ' SPI master out serial in to slave SPI_CS = 2 ' SPI chip select (active low) SPI_SCK = 3 ' SPI clock from master to all slaves WIZ_INT = 13 WIZ_RESET = 14 WIZ_SPI_MODE = 15 DHCP_SOCKET = 3 DNS_SOCKET = 2 rx_buf_size = 512 timeout_retrys = 4 VAR byte ip[3] byte rxString[rx_buf_size], rxStringCheckSum[8] byte rxByte byte headerString[512] OBJ pst : "Parallax Serial Terminal" wiz : "W5100" sock : "Socket" dhcp : "Dhcp" dns : "Dns" propcom : "FullDuplexSerial.spin" DAT request_head byte "POST ", $0 request_URL byte "/index.htm", $0 request_tail byte " HTTP/1.1", CR, LF, $0 request_agent byte "User-Agent: Wiz5200", CR, LF, CR, LF, $0 buff byte $0[BUFFER_2K] t1 long $0 null long $00 headerElement word @request_head, @request_URL, @request_tail, @request_agent PUB Main | retry_ctr, led, x, con_counter, T, bytesToRead, buffer, bytesSent, receiving, remoteIP, dnsServer, totalBytes, i, dnsInit propcom.start(24,25,0,9600) 'Start(rxPin, txPin, mode, baudrate) : okay pst.Start(115_200) pause(500) pst.str(string("START", CR)) repeat LedBool(TRUE) wiz.HardReset(WIZ_RESET) t1 := $0 con_counter := 0 dnsInit := 0 receiving := true bytesToRead := 0 pause(3000) 'a little rest time pst.str(string("Initialize W5100", CR)) wiz.Start(SPI_CS, SPI_SCK, SPI_MOSI, SPI_MISO) wiz.SetMac(MAC_ADDRESS[0], MAC_ADDRESS[1], MAC_ADDRESS[2], MAC_ADDRESS[3], MAC_ADDRESS[4], MAC_ADDRESS[5]) pause(500) 'a little rest time pst.str(string("Getting network paramters", CR)) dhcp.Init(@buff, DHCP_SOCKET) pst.str(string("Requesting IP.....")) repeat until dhcp.DoDhcp(true) pst.str(string("Request", CR)) if(++t1 > DHCP_ATTEMPTS) pst.str(string("*__Can't Obtain IP From DHCP__*", CR)) quit if(t1 > DHCP_ATTEMPTS) pst.char(CR) pst.str(string(CR, "DHCP Attempts: ")) pst.dec(t1) pst.str(string(CR, "Error Code: ")) pst.dec(dhcp.GetErrorCode) pst.char(CR) pst.str(dhcp.GetErrorMessage) pst.char(CR) wiz.HardReset(WIZ_RESET) wiz.Stop LedBool(FALSE) pst.str(string(" Going To Restart In 10 Seconds")) pause(10000) NEXT else pst.str(string("SUCCESS")) PrintIp(dhcp.GetIp) { Stress test repeat pst.str(string("Requesting IP.....")) t1 := 0 'wiz.SetIp(0,0,0,0) repeat until dhcp.RenewDhcp if(++t1 > ATTEMPTS) quit if(t1 > ATTEMPTS) pst.char(CR) pst.str(string(CR, "DHCP Attempts: ")) pst.dec(t1) pst.str(string(CR, "Error Code: ")) pst.dec(dhcp.GetErrorCode) pst.char(CR) pst.str(dhcp.GetErrorMessage) pst.char(CR) return else PrintIp(dhcp.GetIp) 'pause(2000) } pst.str(string("Lease Time........")) pst.dec(dhcp.GetLeaseTime) pst.char(CR) dnsServer := wiz.GetDns pst.str(string("DNS Init (bool)...")) if(dns.Init(@buff, DNS_SOCKET)) pst.str(string("True")) else pst.str(string("False")) pst.char(CR) remoteIP := @ip 'pst.str(string("Initialize Socket")) buffer := sock.Init(0, TCP, RECV_PORT) sock.RemoteIp(Server_IP[0],Server_IP[1],Server_IP[2],Server_IP[3]) sock.RemotePort(SEND_PORT) 'Main Loop sock.Open pause(300) repeat while con_counter < DISCONNECT_ATTEMPTS pause(3500) pst.char(%00) T := cnt pst.str(string("-CONNECTING")) sock.Connect LedBool(TRUE) repeat until sock.Connected <> 0 or con_counter > DISCONNECT_ATTEMPTS if ||((T - cnt)/clkfreq) > 5 T := cnt con_counter += 1 sock.Disconnect pause(500) sock.Connect pst.str(string("-RETRY")) if con_counter > DISCONNECT_ATTEMPTS pst.str(string("-FAIL")) NEXT pst.str(string("-OK")) '/////////////////////////////////USED ONLY WHERE THERE IS A SERIAL SENSOR BOARD ATTACHED. '/////////////////////////////////OTHERWISE THIS WILL NOT RUN IN SIMULATION MODE!!! if SimMode == False propcom.rxFlush bytefill(@rxString,0,rx_buf_size) bytefill(@rxStringCheckSum,0,8) repeat while rxByte <> "/" rxByte := propcom.rx if rxByte == "/" repeat rxByte := propcom.rx if rxByte == "?" quit bytemove(@rxStringCheckSum+strsize(@rxStringCheckSum),@rxByte,1) repeat rxByte := propcom.rx if rxByte == "$" quit 'pst.str(@rxString) bytemove(@rxString+strsize(@rxString),@rxByte,1) bytefill(@headerString ,0,strsize(@headerString)) bytemove(@headerString + strsize(@headerString),@@headerElement[0],strsize(@@headerElement[0])) bytemove(@headerString + strsize(@headerString),@@headerElement[1],strsize(@@headerElement[1])) bytemove(@headerString + strsize(@headerString),string("?node_id="), strsize(string("?node_id="))) bytemove(@headerString + strsize(@headerString),@MODULE_NAME , strsize(@MODULE_NAME )) bytemove(@headerString + strsize(@headerString),string("&site_data=True"), strsize(string("&site_data=True"))) if SimMode == True bytemove(@headerString + strsize(@headerString),@SimulationString,strsize(@SimulationString)) else bytemove(@headerString + strsize(@headerString),@rxString,strsize(@rxString)) 'DATA FROM SERIAL!!!!!!!!!!!!! bytemove(@headerString + strsize(@headerString),@@headerElement[2],strsize(@@headerElement[2])) bytemove(@headerString + strsize(@headerString),@@headerElement[3],strsize(@@headerElement[3])) pst.str(string(CR, "-SENDING")) bytesSent := sock.Send(@headerString, strsize(@headerString)) 'pst.str(@headerString) totalBytes := 0 receiving := True retry_ctr := 0 repeat while receiving LedBool(FALSE) 'Data in the buffer? bytesToRead := sock.Available totalBytes += bytesToRead 'Check for a timeout if(bytesToRead < 0) retry_ctr += 1 if retry_ctr > timeout_retrys or sock.Connected == 0 pst.str(string(CR, "There Was A Disturbance In The Force...", CR)) sock.Disconnect receiving := False retry_ctr := 0 con_counter += 1 next bytesSent := sock.Send(@headerString, strsize(@headerString)) pst.str(string("Timeout", CR)) if(bytesToRead == 0) receiving := false 'pst.str(string(CR, "Done Receiving Response", CR)) next if(bytesToRead > 0) 'Get the Rx buffer buffer := sock.Receive(@buff, bytesToRead) 'dpst.char(SOH) 'pst.str(string("Got Bytes In Buffer") ) pst.str(buffer) bytesToRead~ pause(200) sock.Disconnect pause(200) sock.Close pst.str(string("-REBOOTING!!!", CR)) pause(200) REBOOT PUB PrintIp(addr) | i i := 0 repeat i from 0 to 3 pst.dec(byte[addr][i] & $FF) if(i < 3) pst.char($2E) else pst.char($0D) PRI pause(Duration) waitcnt(((clkfreq / 1_000 * Duration - 3932) #> 381) + cnt) return PRI LedBool(state) dira[23]~~ case state True : 'pst.str(string(13,"LED ON!!",13)) outa[23]~~ False : 'pst.str(string(13,"LED OFF!!",13)) outa[23]~ returnPlease see the attached unit test. This test invokes the DHCP and DNS clients followed by an HTTP request to /finance/historical and finally a reboot. The test ran for 15 minutes without error.