Shop OBEX P1 Docs P2 Docs Learn Events
WizNet W5100 — Parallax Forums

WizNet W5100

DynamoBenDynamoBen Posts: 366
edited 2009-12-27 20:18 in Propeller 1
I'm posting to see how many ppl are using the W5100 in their projects. More importantly if anyone has a decent driver for it using SPI?

At the moment I'm using the Hydra driver, while comprehensive its not very fast. The project I'm working on is listening to a UDP stream that sends data at 1.4-1.6MBps. I had considered marrying the Hydra driver spin code with the SPI_ASM object to see if that would speed things up, but wanted to see if anyone else had done work on this first or had thoughts on the matter.
«1

Comments

  • StefanL38StefanL38 Posts: 2,292
    edited 2009-10-26 21:20
    oh 1.6 MByte per second or 1.6 Megabit per second

    anyway both are high bandwiths.
    As you have to do some SPI-overhead this might be to fast for the propeller. But I'm not sure.

    In other threads some high-speed serial connections are discussed if I remember right for simple serial bitbanging
    the were at 1.7MBs and 10 MBs (don't remember byte or bits per second)

    If you have to do a lot of SPI-overhead (which I don't know) it might be too fast

    Maybe the experts about SPI can chime in ?

    best regards

    Stefan
  • DynamoBenDynamoBen Posts: 366
    edited 2009-10-26 21:39
    I have 2400 bytes being streamed at 40Hz. Which means I have only 96Kbytes/sec that need to be parsed. The hydra driver at present does about 7.8Kbytes/sec.
  • Patrick1abPatrick1ab Posts: 136
    edited 2009-10-27 22:52
    Oh dear, I ordered the Wiz812MJ-Board (which is based on the W5100) today, because I wanted to get some speed improvements. confused.gif

    I've been working with the ENC28J60-Chip until now, using the latest TCP/IP-Stack programmed by Harrison Pham and the fsrw-object to read from sd-card.
    My "Webserver" with these two SPIs reached a maximum speed of 690 KBits/sec which is 86,25 KBytes/sec.


    And now look at this bandwidth provided by the hydra driver: 7.8 KBytes/sec freaked.gif

    I can't really understand why it's so slow.

    Okay, the buffer size of 2 KBytes is surely one part of this problem (I'm working with 4 KBytes on the ENC28J60 at the moment),
    but it doesn't explain a bandwidth loss by a factor of eleven.
  • DynamoBenDynamoBen Posts: 366
    edited 2009-10-27 23:04
    Patrick1ab said...

    I can't really understand why it's so slow.

    Okay, the buffer size of 2 KBytes is surely one part of this problem (I'm working with 4 KBytes on the ENC28J60 at the moment),
    but it doesn't explain a bandwidth loss by a factor of eleven.

    This really isn't the fault of the WizNet I believe its the driver I'm using. You can extend the size of the buffer, its 2K per socket by default, in software. Now you understand my request for something better. smile.gif What kind of numbers are you shooting for?

    Post Edited (DynamoBen) : 10/28/2009 12:18:14 AM GMT
  • Patrick1abPatrick1ab Posts: 136
    edited 2009-10-28 00:30
    DynamoBen said...
    Now you understand my request for something better. [noparse];)[/noparse]

    Yeah, I do wink.gif



    But still, I don't understand where the bottleneck of this driver is ...

    The source code of the ENC28J60 driver + TCP/IP Stack is much bigger and has a lot more instructions to be processed by the propeller.



    I'll try to find a solution tomorrow comparing the different SPI implementations.


    It would be great, if I could get 1.5 MBits/sec. But I don't know if that's possible ...

    Post Edited (Patrick1ab) : 10/28/2009 12:37:18 AM GMT
  • DynamoBenDynamoBen Posts: 366
    edited 2009-10-28 00:55
    Patrick1ab said...

    But still, I don't understand where the bottleneck of this driver is ...

    The source code of the ENC28J60 driver + TCP/IP Stack is much bigger and has a lot more instructions to be processed by the propeller.



    I'll try to find a solution tomorrow comparing the different SPI implementations.

    This is a great point, I will have to speed a little time in the ENC driver also to see how its different.
  • DynamoBenDynamoBen Posts: 366
    edited 2009-10-29 04:05
    I see one big difference in the ENC driver it uses the cog Counter module to clock data in and out. Interesting...
  • Mike HuseltonMike Huselton Posts: 746
    edited 2009-10-29 04:20
    Judicious use of the native COG counters explains the ENC driver's low computational overhead, resulting in the high-speed results you see.

    Try using that technique for the other driver - then it will fly.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • DynamoBenDynamoBen Posts: 366
    edited 2009-10-29 04:38
    James Michael Huselton said...
    Judicious use of the native COG counters explains the ENC driver's low computational overhead, resulting in the high-speed results you see.

    Try using that technique for the other driver - then it will fly.

    Good tip, thanks!!
  • Mike HuseltonMike Huselton Posts: 746
    edited 2009-10-29 04:57
    No worries, mate.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • DynamoBenDynamoBen Posts: 366
    edited 2009-10-29 18:36
    I just reread the AN001 app note about Counters and I'm starting to wrap my head around how they are used in the ENC driver.

    Using this technique in combination with the wiznet “unit of 32-bit stream," which means each 32bit stream contains one data byte. I believe we should be able to write @ 625K databytes/sec and read @ 312.5K databytes/sec (20,000,000/32 - 10,000,000/32). Do my numbers look correct?

    Post Edited (DynamoBen) : 10/30/2009 6:11:04 PM GMT
  • DynamoBenDynamoBen Posts: 366
    edited 2009-10-30 17:26
    It seems my numbers are a touch off. In my previous post I was assuming I had to shiftin 32 bits, which isn't the case. To read I have to shiftout 24bits and shiftin 8, which should dramatically increase the read numbers. Also the numbers above represent the actual SPI read/write loop times in ASM, things should slow down a little when the additional flow control logic is added in.

    Assuming 20MHz for write and 10Mhz for read we should see about 546.875K databytes/sec for reading overall.

    Post Edited (DynamoBen) : 10/30/2009 6:10:20 PM GMT
  • Patrick1abPatrick1ab Posts: 136
    edited 2009-10-30 18:44
    Looks great. I just got my wiz812mj-Board today, so now I can also try to work on this driver.
  • DynamoBenDynamoBen Posts: 366
    edited 2009-10-30 18:50
    Patrick1ab said...
    Looks great. I just got my wiz812mj-Board today, so now I can also try to work on this driver.

    This is what I have so far, the spin portion is mostly the Hydra code, and the PASM is a modified version of the ENC code. This is very raw and untested...I'm sending while I'm still working on it but thought it might give you a boost.
  • Mike HuseltonMike Huselton Posts: 746
    edited 2009-10-30 18:54
    DynamoBen,

    Way to go!

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    JMH
  • Harrison.Harrison. Posts: 484
    edited 2009-10-30 19:37
    Using counters should dramatically increase your transfer speeds. I saw an enormous increase in performance when I switched from bit-banging to counters. You'll get even better performance if you overclock your Propeller to 100MHz (that should yield a SPI clock of 25MHz).

    For comparison, the best SPI clock frequency I could get with a PASM bit-bang loop was ~2.5MHz best case. Using counters gets you clkfreq/4, which is 8 times faster.

    Post Edited (Harrison.) : 10/30/2009 7:42:48 PM GMT
  • Patrick1abPatrick1ab Posts: 136
    edited 2009-10-31 00:37
    DynamoBen said...
    I'm sending while I'm still working on it but thought it might give you a boost.

    Thanks a lot, but it seems I have to fight hardware problems first cry.gif

    Has anyone of you got some experience on how the W5100 reacts when you connect the supply voltage and a network cable (no software/driver started).
    My WIZ812MJ-Board seems to recognize the connection to the computer, but Link- and TX/RX-LEDs are both flashing every few seconds and my computer shows
    connection...no connection...connection...no connection...etc.

    Is this behavior normal, when no initialization has took place? Otherwise I have to assume that my constant voltage regulator is damaged or that I have cold solder joint somewhere.
  • DynamoBenDynamoBen Posts: 366
    edited 2009-10-31 00:49
    Patrick1ab said...

    Has anyone of you got some experience on how the W5100 reacts when you connect the supply voltage and a network cable (no software/driver started).
    My WIZ812MJ-Board seems to recognize the connection to the computer, but Link- and TX/RX-LEDs are both flashing every few seconds and my computer shows
    connection...no connection...connection...no connection...etc.

    Is this behavior normal, when no initialization has took place? Otherwise I have to assume that my constant voltage regulator is damaged or that I have cold solder joint somewhere.

    This is very normal. It won't do a thing until it has a mac, ip, gateway, and subnet mask. Use the hydra driver to test your setup and assign these items.
  • Patrick1abPatrick1ab Posts: 136
    edited 2009-10-31 00:59
    Okay, thanks.

    I already checked the voltage regulator and it's fine, so I'll try to load the hydra driver now.
  • Patrick1abPatrick1ab Posts: 136
    edited 2009-11-03 00:15
    Damn! cry.gif

    I was working on the driver and wondered why my scope suddenly stopped showing Clock-Signal, MOSI, etc. . Then I realized that I couldn't program my Propeller Chip anymore and already thought I had killed it.
    After a while I found out, that the 3.3 V constant voltage regulator of my demo board isn't working properly anymore. It delivers 2.7 V to the Propeller Chip which is the minimum voltage (checking the Propeller's datasheet), but the Propeller won't work in a stable condition at this minimum voltage.

    I hoped that it was just the overload protection (although I can't imagine why it should set off) which is described in the voltage regulators datasheet, but the problem is still there after waiting some time.

    Now I have to find a way to replace it... and I hate replacing SMD-Parts with more than 2 connections


    Forget what I wrote about the voltage regulator. Luckily I checked the switching power supply, which came with my Propeller Demo Board aswell and found out, that it only delivers 4.1V DC although it should have an output of 7.5V DC.

    Post Edited (Patrick1ab) : 11/3/2009 1:44:18 AM GMT
  • Patrick1abPatrick1ab Posts: 136
    edited 2009-11-05 00:57
    Hi Ben!

    Finally, after all my hardware problems, i started testing the early version of your driver:

    Looking at the output of my scope, I can see that the assembler part of the driver seems to recognize that there is a "command" as a parameter (otherwise it would stay in the subloop forever => no change of cspin),
    but it is not able to recognize which type of command it is. So the programm stays in the main loop without jumping to spi_out_ or xspi_in_

    I tried to work on this problem, but my knowledge of assembler is very limited. Especially when it comes to shifting of bits.
  • DynamoBenDynamoBen Posts: 366
    edited 2009-11-05 03:54
    Patrick1ab said...
    Hi Ben!

    Finally, after all my hardware problems, i started testing the early version of your driver:

    Looking at the output of my scope, I can see that the assembler part of the driver seems to recognize that there is a "command" as a parameter (otherwise it would stay in the subloop forever => no change of cspin),
    but it is not able to recognize which type of command it is. So the programm stays in the main loop without jumping to spi_out_ or xspi_in_

    I tried to work on this problem, but my knowledge of assembler is very limited. Especially when it comes to shifting of bits.

    Its a work in progress and frankly I didn't expect that it would work since the code is incomplete. I'm trying to stitch together to very different drivers into one working driver, which isn't always easy. The problem is at the moment I'm in the mist of another project and can't give this a lot of attention. However I hope to get back to it soon.
  • Patrick1abPatrick1ab Posts: 136
    edited 2009-11-06 00:56
    I made a few slight changes (don't expect to much) to the driver and now the signals on my scope look much better, but still I can't get the SPI working.


    There are some issues we should think about:

    1. I'm not sure whether the W5100 can handle a 20MHz SPI, as in the datasheet the minimum SCLK time is 70 ns (20MHz is equal to 50 ns).

    2. Is it necessary to connect the Reset pin? I would like to keep the interface as simple as possible so I commented out the parts where the Reset pin was defined.




    In the attachments you'll also find a simple test program I wrote to check the SPI communication:
    It tries to read the ip address which is currently set, write a new ip address to the W5100 and then reads it again to check whether or not writing has been successful.
    Note that you'll have to connect a tv in order to see the results of this test.




  • DynamoBenDynamoBen Posts: 366
    edited 2009-11-06 22:36
    Patrick1ab said...
    I made a few slight changes (don't expect to much) to the driver and now the signals on my scope look much better, but still I can't get the SPI working.

    I think this is a spin versus ASM issue. The spin code was written for the WizNet whereas the AMS was written for the ENC, that relationship needs "smoothing over".

    Patrick1ab said...
    1. I'm not sure whether the W5100 can handle a 20MHz SPI, as in the datasheet the minimum SCLK time is 70 ns (20MHz is equal to 50 ns).

    I hadn't seen this, what page? Its always easier to go slower [noparse];)[/noparse]
    Patrick1ab said...
    2. Is it necessary to connect the Reset pin? I would like to keep the interface as simple as possible so I commented out the parts where the Reset pin was defined.

    I'd like to say the reset is unneeded but I won't know for sure until I do some more testing and development.
  • Patrick1abPatrick1ab Posts: 136
    edited 2009-11-10 17:09
    We nearly made it...



    After some bugfixes in the assembler part and a few modifications in the "in" function, I was able to read and write data with my test program.

    The only major problem left is that there are still some SPI timing or speed difficulties. Sometimes the data is written and read back correctly, the next time an error occurs.

    DynamoBen said...
    I hadn't seen this, what page? Its always easier to go slower [noparse];)[/noparse]

    You can find this on page 65 of the W5100 datasheet.

    Do you think we can go to a 14.285714 MHz SPI Clock? I know that this is mathematically questionable. scool.gif



    I will try to measure the input and output setup and hold times aswell, although I don't think that these are so critical.


    Edit: This is absolutely crazy... I switched everything off and went to a presentation and now when I returned the driver won't work anymore (it's not even writing false data). I'm pretty sure I saved everything and even wrote the program into the eeprom.

    Post Edited (Patrick1ab) : 11/10/2009 10:36:27 PM GMT
  • DynamoBenDynamoBen Posts: 366
    edited 2009-11-10 22:51
    Patrick1ab said...

    Edit: This is absolutely crazy... I switched everything off and went to a presentation and now when I returned the driver won't work anymore (it's not even writing false data). I'm pretty sure I saved everything and even wrote the program into the eeprom.

    I had this issue too when I was originally editing the code, it worked for hours but then would stop. Make sure the reset pin is tied correctly, a floating reset could do this.
  • DynamoBenDynamoBen Posts: 366
    edited 2009-11-10 22:54
    Patrick1ab said...

    The only major problem left is that there are still some SPI timing or speed difficulties. Sometimes the data is written and read back correctly, the next time an error occurs.

    You can find this on page 65 of the W5100 datasheet.

    Do you think we can go to a 14.285714 MHz SPI Clock? I know that this is mathematically questionable. scool.gif

    Good news so far. The only thing I can think of is change the clock of the out to 10Mhz (like the in) and add a nop between each of the rol commands. The nop will burn up the 4 clocks necessary for 10Mhz.

    Post Edited (DynamoBen) : 11/10/2009 11:13:20 PM GMT
  • Patrick1abPatrick1ab Posts: 136
    edited 2009-11-11 01:53
    DynamoBen said...
    Good news so far. The only thing I can think of is change the clock of the out to 10Mhz (like the in) and add a nop between each of the rol commands. The nop will burn up the 4 clocks necessary for 10Mhz.

    lol... That's exactly what I did in the meantime

    Now the SPI communication works perfectly, but it seems I have some difficulties establishing a connection to my router/pc.

    Do you know which value should be set as source port while calling "open"?
    The destination port should be 80 (webserver) and the destination ip is unknown, so I have set it to 0.0.0.0

    At the moment my webserver is listening, but conn_est never becomes true.
  • DynamoBenDynamoBen Posts: 366
    edited 2009-11-11 01:56
    I assume you are trying to do a TCP connection if so give these examples a look. If not I can post the UDP examples.

    Post Edited (DynamoBen) : 11/11/2009 2:03:14 AM GMT
  • Patrick1abPatrick1ab Posts: 136
    edited 2009-11-11 11:55
    DynamoBen said...
    I assume you are trying to do a TCP connection if so give these examples a look.



    Thanks wink.gif That's what I needed
Sign In or Register to comment.