EtherCard library - pinout question

Status
Not open for further replies.

illwill

Member
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

pinout2a.png Atmega168PinMap2.png


also what would i need to change in the ethercard libs to point to the new pins?
 
Last edited:
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.....
 
have you had any luck?

http://www.kmtronic.com/forum/2-dino-arduino/14-migrate-from-ethershield-to-ethercard-.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:
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.
 
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:
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.
 
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
 
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.)
 
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...
 
Working on Teensy 2.0

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
 
I hope 5 years later I have a reply! :D

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.
 
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?
 
Status
Not open for further replies.
Back
Top