Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 18 of 18

Thread: EtherCard library - pinout question

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    8

    Question EtherCard library - pinout question

    I am switching from an Arduino Duemilanove to the Teensy 2.0 for size.
    I had the Ethercard library working with an ENC28J60 Ethernet Module with this pinout

    ENC28J60------Arduino

    1 Ground------Ground
    2 Power-------VCC
    3 Reset-------Reset
    4 CS----------DigiPin 8
    5 SCK---------DigiPin 13
    6 SI----------DigiPin 11
    7 SO----------DigiPin 12



    I tried hook up to pins 8,11,12,13 on the teensy to make it work, but It doesn't seem to want to pull DHCP


    On the teensy pins is this equivalent to the arduino pins from above?:
    SCK=pb1
    MOSI=pb2
    MISO=pb3
    INT0=pd5

    Click image for larger version. 

Name:	pinout2a.png 
Views:	3991 
Size:	208.2 KB 
ID:	166 Click image for larger version. 

Name:	Atmega168PinMap2.png 
Views:	3662 
Size:	125.5 KB 
ID:	167


    also what would i need to change in the ethercard libs to point to the new pins?
    Last edited by illwill; 01-20-2013 at 04:23 AM.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,748
    At the very least, you'll need to use pins 1, 2, 3 for the SPI port, instead of 13, 11, 12.

    If you'll post a link to the library code and hardware info, I'll take a look.....

  3. #3
    Junior Member
    Join Date
    Jan 2013
    Posts
    8
    I got it from here https://nodeload.github.com/jcw/ethe...acy.zip/master

    if i got the spi pins correct with 1,2,3 then maybe its the pin8 i put to pin5 on the teensy
    or maybe i just have to adjust the library, but not to sure where

    i tried searching for people that were trying to use the teensy for internet stuff but didnt find much oddly enough

  4. #4
    Junior Member
    Join Date
    Jan 2013
    Posts
    8
    have you had any luck?

    http://www.kmtronic.com/forum/2-dino...rcard-.html#17
    this page says you may need to change the pin in a few different files
    In enc28j60.cpp, :
    static byte selectBit; // 0 = B0 = pin 8, 1 = B1 = pin 9, 2 = B2 = pin 10

    In enc28j60.h:
    Line 25: uint8_t csPin = 8 );
    Line 41: static uint8_t doBIST(uint8_t csPin =8 );

    In EtherCard.h:
    Line 134: uint8_t csPin = 8 );
    so maybe if i change csPin =8 to csPin =5
    but in enc28j60.cpp i dont see static byte selectBit;
    Last edited by illwill; 01-22-2013 at 02:10 AM.

  5. #5
    Junior Member
    Join Date
    Jan 2013
    Posts
    2
    ENC28J60's CS should probably be connected to Teensy's PB0, since Arduino's digital 8 = ATmega's PB0.
    The other SPI pins should indeed be connected to PB1, PB2, and PB3 - as mentioned before.

  6. #6
    Junior Member
    Join Date
    Jan 2013
    Posts
    8
    ah oops i put it to PD0 instead of PB0

    i tried defining the pin in my code so i didnt have to change the libraries

    (ether.begin(sizeof Ethernet::buffer, mymac,0)

    the bold 0 should be the PB0 pin , which is pin 0 right?
    Last edited by illwill; 01-22-2013 at 05:02 AM.

  7. #7
    Junior Member
    Join Date
    Jan 2013
    Posts
    2
    Leave it off. Arduino pin 8 = PB0, and the default of the EtherCard library is 8.

  8. #8
    Junior Member
    Join Date
    Jan 2013
    Posts
    8
    tried with it off and still no dice, not sure what i else can check

  9. #9
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,748
    I looked at the code briefly. It seems like these should be the connections:

    1 Ground------Ground
    2 Power-------VCC
    3 Reset-------???
    4 CS----------DigiPin 8 (labeled "D3" on Teensy 2.0 board)
    5 SCK---------DigiPin 1 (labeled "B1" on Teensy 2.0 board)
    6 SI----------DigiPin 2 (labeled "B2" on Teensy 2.0 board)
    7 SO----------DigiPin 3 (labeled "B3" on Teensy 2.0 board)

    The one pin I'm not sure about is the reset pin. My best guess is you would connect to the power.

    On the CS signal, the library lets you specify which pin, but the couple examples I saw didn't specify a pin and just used the default. If you're trying to use the examples as-is, I'd connect to pin 8.

  10. #10
    Junior Member
    Join Date
    Jan 2013
    Posts
    8
    thats how i have it hooked up now and im still getting no dhcp
    the reset pin i hooked into the RST on the teensy

  11. #11
    Junior Member
    Join Date
    Jan 2013
    Posts
    8
    still havent gotten anything working

  12. #12
    Junior Member
    Join Date
    Jan 2013
    Posts
    8
    ill send someone the ENC28J60 ethernet module if they think they can get it working

  13. #13
    Quote Originally Posted by illwill View Post
    ill send someone the ENC28J60 ethernet module if they think they can get it working
    I've already got an ENC28J60 module (this one) but I'm not sure if/when I'll have time to try it out with my Teensy 2.0. (So far, all I've done is run a few examples on my Arduino Uno so I can properly rate the eBay seller)

    The datasheet for the chip does mention that, while it's 5V tolerant, your 5V microcontroller might have trouble making sense of the 3.3V SPI and interrupt inputs without level conversion.

    My first suggestion is to see if you can find any mention of the native USB Arduinos (like the Leonardo and the Micro) being harder to interface with an ENC28J60. (Maybe the older ATMega chips are better at making sense of un-converted 3.3V logic on a 5V input line)

    If I can find the time, I'm actually well-suited to test that hypothesis because I've got a Freaduino Leonardo, which can be switched between 5V and 3.3V operation. (I can't test it right now because I don't have time to dig up the pinout for doing SPI on Arduino boards which only expose it via the programming header. In about 10 minutes, I have to be working.)

  14. #14
    Junior Member
    Join Date
    Nov 2013
    Posts
    1
    This thread has been quiet for a while, but I was searching a solution for the same problem and couldn't find the information readily written from anywhere. Anyways, I'm quite sure I got it working, at least I got an IP w/ DHCP \o/

    I'm using the ethercard lib (as in the first post).

    I got my 3.3V from arduino duemilanove sitting next to the teensy at the moment. It's a little bit of a tweak, but seems to be ok. The pinout I'm using at the moment:
    CLKOUT = Not connected
    WOL = Not connected
    SI = 22/B2 (On teensy 2.0 ++)
    CS = 8/E0 (On teensy 2.0 ++)
    VCC = 3.3V (On arduino dueminalove!!)
    INT = 2/D2 (On teensy 2.0 ++)
    SO = 23/B3 (On teensy 2.0 ++)
    SCK = 21/B1 (On teensy 2.0 ++)
    RESET = RST (On teensy 2.0 ++)
    GND = GND (On teensy 2.0 ++)

    I am also powering the arduino dueminalove from teensy 2.0 ++ by connecting:
    GND on teensy to GND on arduino
    +5V on teensy to VIN on arduino

    By powering the setup this way I can be sure that there's no potential differences between boards and the 3.3V coming from the arduinos pin is truly 3.3V for teensy also. Arduino does not have any power or usb -cables connected, I'm just using it as a regulator for 5V -> 3.3V!

    Teensy has the usb connected of course.

    The code I'm using for teensy is the example code in ethercard library called testDHCP (with no modifications). Arduino/teensyduino -environment version is 1.05.

    I'll try to remember to provide more details for when I get to clean up the mess and get rid of the arduino giving the 3.3V.

    This should be easily modified for Teensy 2.0 with the SPI pin table at http://www.pjrc.com/teensy/td_libs_SPI.html, the SS should probably stay at the pin 8 of the teensy 2.0 though...

  15. #15
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    19,748
    Wow, I believe this is the first time I've ever heard someone confirm the ENC28J60 actually works!

  16. #16
    Junior Member
    Join Date
    May 2014
    Posts
    1

    Lightbulb Working on Teensy 2.0

    Quote Originally Posted by PaulStoffregen View Post
    Wow, I believe this is the first time I've ever heard someone confirm the ENC28J60 actually works!
    Know it's an old thread, but for reference, got it to work on a Teensy 2.0. Pretty straight forward(after a few trial runs

    Started with converting my Teensy 2.0 to run 3.3v so I did not have to worry about logic levels.

    And then wired the ENC28J60 to the Teensy 2.0 like this.

    INT -> D1 (INT1)
    SO -> B3 (MISO)
    SI -> B2 (MOSI)
    SCK ->B1 (SCLK)
    CS -> D3 (INT3)

    Works like a charm.

    /Mads

  17. #17

    I hope 5 years later I have a reply! :D

    Quote Originally Posted by Magiske View Post
    Know it's an old thread, but for reference, got it to work on a Teensy 2.0. Pretty straight forward(after a few trial runs

    Started with converting my Teensy 2.0 to run 3.3v so I did not have to worry about logic levels.

    And then wired the ENC28J60 to the Teensy 2.0 like this.

    INT -> D1 (INT1)
    SO -> B3 (MISO)
    SI -> B2 (MOSI)
    SCK ->B1 (SCLK)
    CS -> D3 (INT3)

    Works like a charm.

    /Mads
    I know this thread is ancient. But I'm in some kind of trouble and I found this and this is the only place where I finally got this issue working. This is on the last updated Ethercard library isn't it? I'm doing the wiring right now on the teensy 2.0 and teste it and if I got feedback will post the result! Thank you very much guys.

  18. #18
    Quote Originally Posted by JoseArguello View Post
    I know this thread is ancient. But I'm in some kind of trouble and I found this and this is the only place where I finally got this issue working. This is on the last updated Ethercard library isn't it? I'm doing the wiring right now on the teensy 2.0 and teste it and if I got feedback will post the result! Thank you very much guys.
    Also do you have another option for pin D1? I'm using I2C port on a display and can't use this pin, I'm wiring INT to pin D2(INT2) instead, is this right?

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •