SPI Device (Ethernet Shield) on the Papilio DUO


cjr

Recommended Posts

Hello everybody,

 

first i would like to say that my problem has nothing to do with the FPGA part, i'm not using any soft processor in the FPGA.

 

I would like to connect an Arduino Ethernet Shield (with the W5100 chip) to the AVR part of my DUO.

 

I already have an ENC28J60 card running with the UIPEthernet library, this card is also connected via SPI.

 

BUT:

 

For the ENC28J60 i needed to set the SPI pins to

 

#define UIP_FORCE_SS           53
#define UIP_FORCE_SCK         52
#define UIP_FORCE_MOSI        51
#define UIP_FORCE_MISO        50

 

(these UIP_FORCE constants were invented by myself). This is working! But i don't understand it :o , because the AVR does not have these high output pin numbers ?!?

 

The standard ethernet library for the Arduino Ethernet Shield obviously uses some other pins, but i'm unable to extract the pins from the library source code, this is all very confusing. What is NOT working:

 

SCK   13

MISO 12

MOSI 11

SS 10 or 8

 

I know that i have to connect these Arduino Pins from the DUO to the ICP header at the Ethernet Shield.

 

Well, this is all very mysterious. Maybe someone could tell me simply which Pins on the DUO are the official SPI connections? I will also try some other SPI device in the meantime.

Best Regards,

 

Christof

Link to comment
Share on other sites

Hello Christof,

 

This sounds strange, I just double checked the schematic and you should be able to use:

 

SCK   13

MISO 12

MOSI 11

SS 10 or 8

 

The only explanation for you needing to use the other pins is that you have a circuit loaded to the FPGA that is connecting the SPI pins to those other FPGA pins. Do you know what circuit you are running on the FPGA? If you want to use the physically connected pins 10-13 then you can add the following to your sketch:

#define circuit blank

Then be sure to click on the, "Load Circuit" icon to load that blank circuit to the FPGA. You can also view the circuit and see that it is only connecting the SW1 switch to the reset pin of the AVR. So you will need to insure that SW1 is in the upright position.

 

Please let us know what you find, I'm going to Maker Faire New York this weekend so will be away from the computer for several days but will try to help from my phone as I can.

 

Also, here are some resources for the DUO:

 

Main Page

Pinout Guide

Hardware Guide

 

Jack.

Link to comment
Share on other sites

Although i have my own circuit in the FPGA, i'm sure that i'm not using pins 10-13. Because my FPGA circuit is also active when i'm using the sketch with the EtherCard with the same physical pins, where it is working OK.

 

Nevertheless, i will try it with the blank circuit in the FPGA and tell You the result.

 

Ok, i think my original post was not clear enough:

 

The ENC28J60 is attached to the physical pins 10-13, but i had to tell the UIPEthernet Library to use Pins 50-53. This crazy configuration is WORKING! That's why i'm confused. I don't understand why the UIPEthernet Library will not work with pins 10-13.

 

SW1 is connected correctly in my circuit, Reset is working fine.

 

I already studied all the resources, pinouts, diagrams and so on, i even traced some signals on the PCB :-)

Link to comment
Share on other sites

Looks like i've found the culprit. The standard Ethernet Library (from the Arduino IDE, library version 1.0.5, because there is no Ethernet Library with DesignLab) implements some shortcuts for the SPI "Slave Select" pin. The inlines for the SS pin are defined as

 

  inline static void initSS()    { DDRB  |=  _BV(6); };
  inline static void setSS()     { PORTB &= ~_BV(6); };
  inline static void resetSS()   { PORTB |=  _BV(6); };
 

if the __AVR_ATmega32U4__ symbol is defined, like it is on the Papilio Duo. Pin B6 is pin 14 on the PCB, so no wonder it's not working. I changed the 3 inlines to  _BV(0) (aka pin 10 on the PCB), now it's working.

 

Is there a predefined symbol like "IM_A_PAPILIO_DUO" or something like that in DesignLab? Then i could use some #ifdefs in the Ethernet Library and recommend this also to the  author of the library.

 

Best Regards,

 

Christof.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.