Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Document pin usage of Ethernet library. [imported] #662

Closed
@cmaglie

Description

This is Issue 662 moved from a Google Code project.
Added by 2011年10月01日T18:34:38.000Z by go4s...@gmail.com.
Please review that bug for more context and additional comments, but update this bug.
Closed (Fixed).

Original labels: Type-Defect, Priority-Medium, Component-Docs

Original description

I am programming an Arduino Mega (ATmega1280) with the ether network module (WIZnet WIZ811MJ) (http://www.sparkfun.com/products/9473).
I am using the SPI and Ethernet libraries.
According to http://arduino.cc/en/Main/ArduinoBoardMega the Arduino MEGA's SPI pins are 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS).
But if I look at the code that manipulates SS arduino-0022\libraries\Ethernet\utility\w5100.h (line 311):

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
 inline static void initSS() { DDRB |= _BV(4); };
 inline static void setSS() { PORTB &= ~_BV(4); };
 inline static void resetSS() { PORTB |= _BV(4); };
#else
 inline static void initSS() { DDRB |= _BV(2); };
 inline static void setSS() { PORTB &= ~_BV(2); };
 inline static void resetSS() { PORTB |= _BV(2); };
#endif

The code addresses PORT B pin 4 (PB4) which is Arduino MEGAs pin 10 (and NOT 53).
For the Arduino MEGAs PORT B pin 0 (PB0) should be used to get pin 53.

I changed the code to:

#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
 inline static void initSS() { DDRB |= _BV(0); };
 inline static void setSS() { PORTB &= ~_BV(0); };
 inline static void resetSS() { PORTB |= _BV(0); };
#else
 inline static void initSS() { DDRB |= _BV(2); };
 inline static void setSS() { PORTB &= ~_BV(2); };
 inline static void resetSS() { PORTB |= _BV(2); };
#endif

and now SPI works as advertised: 50 (MISO), 51 (MOSI), 52 (SCK), 53 (SS).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /