Can you also help me with this? I have copied the SD library in this post to the Arduino Libraries folder. When I compile I get errors show below…
I have recently purchased Dash device.
My connections are:
SCK (L05)
MOSI (L06)
MISO (L08)
SS (L07)
Sd2Card.h:26: In file included from
Sd2Card.cpp:22: from
Sd2Card.cpp: In function void spiSend(uint8_t)
Sd2PinMap.h: 28:20: error: ‘AltSPI’ was not declared in this scope
#define SDCARD_SPI AltSPI
Sd2Card.cpp:42: note in expansion of macro SDCARD_SPI
SDCARD_SPI.transfer(b)
Sd2Card.cpp: In function uint8_t spiRec()
Sd2PinMap.h: 28:20: error: ‘AltSPI’ was not declared in this scope
#define SDCARD_SPI AltSPI
Sd2Card.cpp:51: note in expansion of macro SDCARD_SPI
return SDCARD_SPI.transfer(0xFF)
Sd2Card.cpp: In function void spiRec(uint8_t*, int)
Sd2PinMap.h: 28:20: error: ‘AltSPI’ was not declared in this scope
#define SDCARD_SPI AltSPI
Sd2Card.cpp:112: note in expansion of macro SDCARD_SPI
SDCARD_SPI.transfer(data, size)
Sd2Card.cpp: In member function void Sd2Card::chipSelectHigh()
Sd2PinMap.h: 28:20: error: ‘AltSPI’ was not declared in this scope
#define SDCARD_SPI AltSPI
Sd2Card.cpp:184: note in expansion of macro SDCARD_SPI
SDCARD_SPI.endTransaction()
Sd2Card.cpp: In member function void Sd2Card::chipSelectLow()
Sd2PinMap.h: 28:20: error: ‘AltSPI’ was not declared in this scope
#define SDCARD_SPI AltSPI
Sd2Card.cpp:193: note in expansion of macro SDCARD_SPI
SDCARD_SPI.beginTransaction(chipSelectPin_, settings)
Sd2Card.cpp: In member function uint8_t Sd2Card::init(uint8_t, uint8_t)
Sd2PinMap.h: 28:20: error: ‘AltSPI’ was not declared in this scope
#define SDCARD_SPI AltSPI
Sd2Card.cpp:285: note in expansion of macro SDCARD_SPI
SDCARD_SPI.begin()
Error compiling libraries
Build failed for project ‘SD Testing’
************** UPDATE ****************************************************
I managed to solve the problem but not sure why. I noted when I ran cardinfo sketch, the card was initialized ok but when I ran the datalogger sketch that used SD.begin, the code just locked up. After playing around a bit I did this (Ran card.init and then SD.begin). Now I can perform all the file activity ok.
if (!card.init(SPI_HALF_SPEED, chipSelect)) {
Serial.println(“SD init failed”);
return;
}
else {
Serial.println(“SD ok”);
}
SD.begin();