Shop OBEX P1 Docs P2 Docs Learn Events
Using INDIRECT driver — Parallax Forums

Using INDIRECT driver

agsags Posts: 386
edited 2011-05-08 22:00 in Accessories
Is anyone using the INDIRECT driver for the WIZnet module? I took a perfectly functioning prototype (uptime >20 days) and switched it from SPI to INDIRECT, and now it's completely unreliable. I'm pretty sure the connections are correct, as it works sometimes. However, I can't seem to even write a MAC address and then read it back and compare the values correctly.

BTW, I pulled the latest revision (0.12) from the Google code repository today.

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-05-04 06:28
    I use the indirect driver, it works fine. I modified it a little for my needs but the basic getters and setters are the same.

    Someone else reported similar symptoms with both SPI and Indirect drivers.

    If you post your code I can run it on my Spinneret and report back.
  • agsags Posts: 386
    edited 2011-05-04 12:39
    OK, here's the basic code. It just writes then reads basic settings (MAC, IP, Subnet & Gateway). I am getting the same (incorrect) results after reading back the values written. That is to say, it's not an intermittent problem. Note that I'm not using a Spinneret, I'm using the WIZMJ812 module connected to my Prop Protoboard. I suspect the problem may be caused by me not using the SEN pin and my DATA pins start at Prop P7.

    Note you'll need to change the pin values, and the path to the WIZnet driver. I've made a copy to try to debug. On my setup, when I write MAC 00:00:00:00:FF:FF I read back 00:00:00:00:FF:00 the first time, and 00:00:00:00:FF:C0 in the "dump" output. When I write 255.255.255.0 as the SubnetMask, I read back 255.255.0.0 both times. The IP address and Gateway Address are OK.

    Thanks for any ideas.
    CON
      _clkmode = xtal1 + pll16x
      _xinfreq = 5_000_000
     
      'WIZ module INDIRECT I/O
      ADDR0_PIN       = 1            ' Address bit 0 (out)
      ADDR1_PIN       = 2            ' Address bit 1 (out)
      CS_PIN          = 3            ' Chip Select (out)
      RD_PIN          = 4            ' Read (out)       
      WR_PIN          = 5            ' Write (out)
      RESET_PIN       = 6            ' Reset (out)
      DATA_START_PIN  = 7            ' Data (in/out)
      SEN_PIN         = -1           ' SPI ENABLE PIN IS UNUSED
    VAR
      byte dbgArray[512]
     
    DAT
      MACaddr     byte      $00, $00, $00, $00, $FF, $FF
      IP          byte      192,168,1,127
      GatewayIP   byte      192,168,1,254
      SubnetMask  byte      255,255,255,0
    OBJ
      W5100         : "W5100_Indirect_Driver_CUSTOM"                   
      PST           : "Parallax Serial Terminal"
    PUB main
      PST.Start(115_200)
      waitcnt(clkfreq + cnt)
      PST.Home
      PST.Clear
     
      W5100.StartINDIRECT(DATA_START_PIN,ADDR0_PIN,ADDR1_PIN,CS_PIN,RD_PIN,WR_PIN,RESET_PIN,SEN_PIN)
      PauseMSec(2000)
      PrintMAC(@MACaddr)  
      W5100.WriteMACaddress(true,@MACaddr)
      W5100.ReadMACaddress(@dbgArray)
      PrintMAC(@dbgArray)
      PrintIP(@IP)
      W5100.WriteIPaddress(true, @IP)
      W5100.ReadIPaddress(@dbgArray)
      PrintIP(@dbgArray)
     
      PrintIP(@SubnetMask)
      W5100.WriteSubnetMask(true, @SubnetMask)
      W5100.ReadSubnetMask(@dbgArray)
      PrintIP(@dbgArray)
     
      PrintIP(@GatewayIP)
      W5100.WriteGatewayAddress(true, @GatewayIP)
      W5100.ReadGatewayAddress(@dbgArray)
      PrintIP(@dbgArray)
     
      DumpSettings
     
    PRI DumpSettings
     
        PST.Str(string("WizNet W5100 Module Settings::",PST#NL))
        W5100.ReadMACaddress(@dbgArray) 
        PST.Str(string("MAC Address          : "))               
        PrintMAC(@dbgArray)
     
        W5100.ReadIPaddress(@dbgArray)  
        PST.Str(string("IP Address           : "))                
        PrintIP(@dbgArray)
     
        W5100.ReadSubnetMask(@dbgArray)  
        PST.Str(string("Subnet Mask          : "))                  
        PrintIP(@dbgArray)
     
        W5100.ReadGatewayAddress(@dbgArray)  
        PST.Str(string("Gateway Address      : "))                   
        PrintIP(@dbgArray)
     
    PRI PrintIP(IPptr) | i              
        repeat i from 0 to 3
          PST.Dec(byte[IPptr][i])
          if i <> 3
            PST.Str(string("."))
        PST.Char(PST#NL)
    PRI PrintMAC(MACptr) | i              
        repeat i from 0 to 5
          PST.Hex(byte[MACptr][i],2)
          if i <> 5
            PST.Str(string(":"))
        PST.Char(PST#NL)
     
    PRI PauseMSec(Duration)
    ''  Pause execution for specified milliseconds.
    ''  This routine is based on the set clock frequency.
    ''  
    ''  params:  Duration = number of milliseconds to delay                                                                                               
    ''  return:  none
      waitcnt(((clkfreq / 1_000 * Duration - 3932) #> 381) + cnt)
    
  • Mike GMike G Posts: 2,702
    edited 2011-05-04 14:42
    I'm not sure how much help I can provide... I can tell you that I hit the driver pretty hard. I'm writing all 4 status registers to HUB memory continuously. The statuses are used in a state machine. I tested the code for about two days. The server handled 20,000+ resource requests (HTTP / TCP) without a lockup or crash.
  • agsags Posts: 386
    edited 2011-05-04 21:27
    Still debugging. Very frustrating. I've pruned the test case down to a simple write/read of the MAC address, and it is failing. I've checked my electrical connections >10 times now. There is a possibility that the pinout on the WIZnet data sheet is incorrect, but I would think that would have been caught by others by now (outside the Spinneret community). It also might be a timing problem, as I have jumpers connecting the WIZnet module to a breadboard and then to the Propeller Protoboard.

    Argh.
  • agsags Posts: 386
    edited 2011-05-08 22:00
    It turned out that my long jumpers and solderless breadboard were the cause of the malfunction. Once I hardwired the WIZnet module to the Propeller Protoboard with short wires, it worked fine. Thanks for the replies.
Sign In or Register to comment.