Pages: [1]   Go Down
Author Topic: Using SD libraries with unusual ports  (Read 698 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I'm trying to get a SD card reader to work on a custom arduino board that we had made for running gasifiers.  The board specifications can be seen at:

http://wiki.gekgasifier.com/w/page/6123727/Gasifier-Control-Unit

Unfortunately two of the ports that are connected to the SD card reader are not considered Arduino pins:

PIN NAME,   NUMBER, ARDUINO PIN NUMBER,  SD LIBRARY NAME
PJ0           63        15                         MISO_PIN
PJ1           64        14                         MOSI_PIN
PJ2           65          N/A                           SCK_PIN
PJ3           66          N/A                           SS_PIN

So unfortunately digitalWrite and pinMode both return prematurely because SCK_PIN and SS_PIN's ports are set to NOT_A_PIN.

I've tried updating pins_arduino.c to include two new pins (70 and 71):
Code:
const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
// PORTLIST
// -------------------------------------------
PE , // PE 0 ** 0 ** USART0_RX
PE , // PE 1 ** 1 ** USART0_TX
...
PK , // PK 5 ** 67 ** A13
PK , // PK 6 ** 68 ** A14
PK , // PK 7 ** 69 ** A15
    PJ  , // PJ 2 ** 70 ** SD_CAN_SCK
    PJ  , // PJ 3 ** 71 ** SD_NSS
};

const uint8_t PROGMEM digital_pin_to_bit_mask_PGM[] = {
// PIN IN PORT
// -------------------------------------------
_BV( 0 ) , // PE 0 ** 0 ** USART0_RX
_BV( 1 ) , // PE 1 ** 1 ** USART0_TX
...
_BV( 5 ) , // PK 5 ** 67 ** A13
_BV( 6 ) , // PK 6 ** 68 ** A14
_BV( 7 ) , // PK 7 ** 69 ** A15
      _BV( 2 )    , // PJ 2 ** 70 ** SD_CAN_SCK
     _BV( 3 )    , // PJ 3 ** 71 ** SD_NSS
};


and finally updated Sd2PinMap.h:
Code:
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
// Mega

// Two Wire (aka I2C) ports
uint8_t const SDA_PIN = 20;
uint8_t const SCL_PIN = 21;

// SPI port
uint8_t const SS_PIN = 71;
uint8_t const MOSI_PIN = 14;
uint8_t const MISO_PIN = 15;
uint8_t const SCK_PIN = 70;

static const pin_map_t digitalPinMap[] = {
  {&DDRE, &PINE, &PORTE, 0},  // E0  0
  {&DDRE, &PINE, &PORTE, 1},  // E1  1
...

  {&DDRK, &PINK, &PORTK, 7},  // K7 69
  {&DDRJ, &PINJ, &PORTJ, 2},  // J2 70
  {&DDRJ, &PINJ, &PORTJ, 3}   // J3 71
};

Unfortunately the I still get no response from the sd card with the following function:
Code:
void InitSD() {
  Serial.print("#Initializing SD card...");
  pinMode(SS_PIN, OUTPUT);
  if (!sd_card.init(SPI_HALF_SPEED, SS_PIN)) {
    Serial.println("initialization failed. ");
    sd_loaded = false;
    return;
  } else {
    Serial.println("card initialized.");
    sd_loaded = true;
  }
}

And yes, the 2 gig card is formatted to Fat16.  Is there anything that I'm missing or any suggestion that anyone can make?  Please let me know if there is any other information you all need.

Thanks in advance!
Logged

Pages: [1]   Go Up
Jump to: