WIZnet WIZ810MJ

Matt_C

Member
Does anyone have any idea how to interface a WIZnet WIZ810MJ with a picaxe via SPI and maybe a basic example?

I just feel like I'm dorwning here as I'm a bit out of my depth.

Help???? :confused:
 

Mycroft2152

Senior Member
Hi Matt. It would have been nice to include a link to the data sheet with your request, or maybe even a link to the Circuit Cellar WizNET Design Competition....
 

hippy

Ex-Staff (retired)
http://www.wiznet.co.kr/pro_iin_wiz810mj.htm
http://www.wiznet.co.kr/pro_iin_W5100.htm

The actual SPI seems fairly straight forward and simpler than other SPI schemes I've seen. To send a byte to a register, clock out the 8-bit write opcode, 16-bits of register address and 8-bits of data. To read a byte from a register, clock out the 8-bit read opcode, 16-bits of address, then clock in 8-bits of data. Everything is MSB first.

Begin with bit-banged SPI and worry about any hardware SPI later.

The best way to start would be to read in a register which has a non-zero value and check you get the bits back for that which you'd expect. Failing that, if there isn't one, it's a case of writing values and reading them back. Using Gateway IP address registers should be okay to use this way.

Untested, but the general SPI skeleton should be something like this ...

Code:
' ======== To write a byte to a register

addr = $123
byte = $12
Gosub WriteByteToAddr

' ======== To read a byte from a register

addr = $1234
Gosub ReadByteFromAddr

' ======== The low-level SPI driver code

WriteByteToAddr:
  Low SS
  b0 = $F0        : Gosub SendSpiB0
  b0 = addr \ 256 : Gosub SendSpiB0
  b0 = addr & 255 : Gosub SendSpiB0
  b0 = byte       : Gosub SendSpiB0
  High SS
  Return

ReadByteFromAddr:
  Low SS
  b0 = $0F        : Gosub SendSpiB0
  b0 = addr \ 256 : Gosub SendSpiB0
  b0 = addr & 255 : Gosub SendSpiB0
                    Gosub ReadSpiB0
  High SS
  Return 

SendSpiB0:
  For bitCount = 0 To 7
    If bit7 <> 0 Then
      High DAT
    Else
      Low DAT
    End If
    High SCLK
    Low SCLK
    b0 = b0 * 2
  Next
  Return

ReadSpiB0:
  For bitCount = 0 To 7
    High SCLK
    If pinX <> 0 Then
      b0 = b0 * 2 | 1
    Else
      b0 = b0 * 2 | 0
    End If
    Low SCLK
  Next
  Return
 

Matt_C

Member
Mycroft2152 - Your right, sorry, I d have included more info. I will do better next time. Thanks.

hippy - Thanks for the stater. I need to look closer at how the device works internally as it looks like I need to initialize the W5100 before I do anything else.
 

steliosm

Senior Member
Matt wait 'till we get the modules in our hands first :)
You do need to go through the W5100 datasheet. I'm waiting for my module to arrive :) :)
What are you planing to make?
Maybe another module is more suitable for the task.
 

Matt_C

Member
My mind is buzzing with all sorts of possibilities.
I think the key is to get it to talk to the PICAXE and then we can do what we like.
For a bit of fun I would like to interface to a VCR. Lol.
I was asked today by a friend if at some time I could make a network interface for his AC unit at home.

I have 2 of these units already and I got my hands on a couple of SPI adapter PCB's for these units that will help plug into breadboard and has a few LED's to let you know the state of the unit.



I think I may have stepped in a bit too deep to start with but willing to give it a go.
 

steliosm

Senior Member
Well, about your friend's idea I would go for a web-enabled module such as SimpleLan. You could then use your browse to turn your AC unit on/off and monitor parameters such as temperature in the room. With the Wiznet module you will have to come up with the 'User Interface' as well.

Where did you get the boards for the breadbord? Sparkfun?
 
This is a little out-of-date, I'm not sure it you're still having trouble. Below is the code that I've written so far to interface an 18X with the WIZ810MJ. All it does so far is set the network values -- hardware address, IP address, etc.

It works, I'm able to read data out of the module as well as ping it from another computer on my home network. That was a pretty cool moment, believe me.

I'm using the code from the Picaxe manual to bit-bang the SPI out to the WIZnet module.

The very bottom of the main line code is as far as I've gotten figuring out the "write to TX memory" code. Unfortunately, real life keeps getting in the way and I'm not having as much time as I wanted to work on the project.

Chuck
 

Attachments

Matt_C

Member
Well I can't wait to get the board back out of the cupboard.

I had to put this project on hold as an Air Con fault detection and correction project for 3 AC units in a server room has taken priority. Another couple of weeks and then I have to get on with the next project to control LCD projectors from a PC to the RS232 port of the projector via 433MHz RF.

After all that I should be able to get back to the Wiznet board.

A project I just thought of that would be handy with the Wiznet would be a device that could receive IR and/or RF to execute sending a magic packet to wake a remote PC that has 'wake on lan' set.

Thanks for sharing your code so far puddlehaven.

Please do keep us all updated with your progress and any code updates or snipits you can share with us.
I'm sure I'm not the only one who will benifit from your help.
 
Top