ok thanks
PDE
#include <nodoGenerico.h>
//IMPOSTAZIONI
#define intervalloMinimoTraCampioni 2000 //180000//ritardo fra 2 campioni in millesecondi
#define sdPin 4 //per lo stalker 10, per ethernet shield 4
#define coordnatorAddressMsb 0x0013a200
#define coordnatorAddressLsb 0x406163FD
//include locali
#include "DS1307.h" //i2c clock
#include <SD.h>
#include <XBee.h>
#include <Wire.h>
#include "WProgram.h"
const int nTentativi=3;
const int ritardoProve=2000;
uint8_t timestamp[7];
nodoGenerico provaNodo(0x0013a200, 0x406163FD, nTentativi, ritardoProve);
void setup() {
Serial.begin(9600);
Serial.println("sono nel setup");
}
void loop() {
Serial.println("inizio un loop");
delay(intervalloMinimoTraCampioni);
}
the .cpp
/******************************************************************************
* Includes
******************************************************************************/
#include "nodoGenerico.h"
#include "WProgram.h" //Arduino includes
#include <SD.h>
/******************************************************************************
* Definitions
******************************************************************************/
//#define sdPin 4 //per lo stalker 10, per ethernet shield 4
/******************************************************************************
* Constructors
******************************************************************************/
nodoGenerico::nodoGenerico(uint32_t coordAddMsb, uint32_t coordAddLsb, int nTentativiParam, int ritardoProveParam)
{
Serial.begin(9600);
xbee = XBee();
addr64 = XBeeAddress64(coordAddMsb, coordAddLsb);
txStatus = ZBTxStatusResponse();
sdScritta=false;
sdPresente=false;
nTentativi=nTentativi;
ritardoProve=ritardoProve;
xbee.begin(9600);
//Serial.print("Initializing SD card...");
// On the Ethernet Shield, CS is pin 4. It's set as an output by default.
// Note that even if it's not used as the CS pin, the hardware SS pin
// (10 on most Arduino boards, 53 on the Mega) must be left as an output
// or the SD library functions will not work.
pinMode(10, OUTPUT);
if (!SD.begin(sdPin)) {
Serial.println("initialization failed!");
sdPresente=false;
Serial.println("sono nel costruttore");
}
else{
Serial.println("initialization done.");
sdPresente=true;
//se la sd è presente guardo se è scritta
mioFile = SD.open("valori.txt");
if (mioFile) {
if(mioFile.available()>0 )
sdScritta=true;
mioFile.close();
}
}
}
nodoGenerico::~nodoGenerico( )
{
}
everything compiles well but at running time arduino crashes in SD.begin when reach the function millis() called by the sd library