Pages: [1]   Go Down
Author Topic: Change the pins used by the SD.h library  (Read 933 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am trying to write data to an SD card while simultaneously using the Ethernet libraries to output the logged data to a web page... (I have both these functions working separately).

The problem is the Ethernet library and the SD library both use pins 13, 12, 11, and an SS pin (10).

I have been browsing through the SD.h library and i cannot for the life of me figure out were the pin usage is defined. To be clear i need to change the pins used by the SD library to something else (like 7-4 instead of 13-10).

Would the SD2PinMap utility allow me to do this if I added the board type I have selected?
The SD2PinMap has code blocks that look like this:

Code:
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__)
// Sanguino

// Two Wire (aka I2C) ports
uint8_t const SDA_PIN = 17;
uint8_t const SCL_PIN = 18;

// SPI port
uint8_t const SS_PIN = 4;
uint8_t const MOSI_PIN = 5;
uint8_t const MISO_PIN = 6;
uint8_t const SCK_PIN = 7;

static const pin_map_t digitalPinMap[] = {
  {&DDRB, &PINB, &PORTB, 0},  // B0  0
  {&DDRB, &PINB, &PORTB, 1},  // B1  1
  {&DDRB, &PINB, &PORTB, 2},  // B2  2
  {&DDRB, &PINB, &PORTB, 3},  // B3  3
  {&DDRB, &PINB, &PORTB, 4},  // B4  4
  {&DDRB, &PINB, &PORTB, 5},  // B5  5
  {&DDRB, &PINB, &PORTB, 6},  // B6  6
  {&DDRB, &PINB, &PORTB, 7},  // B7  7
  {&DDRD, &PIND, &PORTD, 0},  // D0  8
  {&DDRD, &PIND, &PORTD, 1},  // D1  9
  {&DDRD, &PIND, &PORTD, 2},  // D2 10
  {&DDRD, &PIND, &PORTD, 3},  // D3 11
  {&DDRD, &PIND, &PORTD, 4},  // D4 12
  {&DDRD, &PIND, &PORTD, 5},  // D5 13
  {&DDRD, &PIND, &PORTD, 6},  // D6 14
  {&DDRD, &PIND, &PORTD, 7},  // D7 15
  {&DDRC, &PINC, &PORTC, 0},  // C0 16
  {&DDRC, &PINC, &PORTC, 1},  // C1 17
  {&DDRC, &PINC, &PORTC, 2},  // C2 18
  {&DDRC, &PINC, &PORTC, 3},  // C3 19
  {&DDRC, &PINC, &PORTC, 4},  // C4 20
  {&DDRC, &PINC, &PORTC, 5},  // C5 21
  {&DDRC, &PINC, &PORTC, 6},  // C6 22
  {&DDRC, &PINC, &PORTC, 7},  // C7 23
  {&DDRA, &PINA, &PORTA, 7},  // A7 24
  {&DDRA, &PINA, &PORTA, 6},  // A6 25
  {&DDRA, &PINA, &PORTA, 5},  // A5 26
  {&DDRA, &PINA, &PORTA, 4},  // A4 27
  {&DDRA, &PINA, &PORTA, 3},  // A3 28
  {&DDRA, &PINA, &PORTA, 2},  // A2 29
  {&DDRA, &PINA, &PORTA, 1},  // A1 30
  {&DDRA, &PINA, &PORTA, 0}   // A0 31
};


Ty for the help smiley-kitty
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 17
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hmm, It seems the SPI communications is handled by a hardware module which is connected to these pins, thus you cannot change them.

Although it is theoretically possible to switch the Ethernet shield and the SD shield on and off when the other is in use... it doesn't work with the sparkfun pro Ethernet board which I have  smiley-neutral
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 139
Posts: 5856
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want help on specific hardware, I suggest you post links to that hardware. If you are using the Sparkfun stuff, the ethernet shield uses D10 for the slave select, and the SD uses D8 for the slave select. Check your hardware datasheet closely or post the links.

Are these the cards you are using?
https://www.sparkfun.com/products/10536
https://www.sparkfun.com/products/9802

edit: If these are the shields, then I should mention it is important how the shields are connected to the Uno. The ethernet shield must be on the bottom. The SD shield should mount on it. The ethernet shield requires the ICSP connector for the SPI data lines.
« Last Edit: February 14, 2013, 09:03:07 am by SurferTim » Logged

Pages: [1]   Go Up
Jump to: