ninja2
Well-known member
When I run this sketch the LED blinks twice during setup, but doesn't flash in loop().
However, if I comment out the if-else SD initialisation, the LED flashes as expected.
Looks like an issue for SdFat lib, but I don't know where to look?
However, if I comment out the if-else SD initialisation, the LED flashes as expected.
Looks like an issue for SdFat lib, but I don't know where to look?
Code:
#include "Streaming.h"
#include "SdFat.h"
#ifdef ARDUINO_TEENSY_MICROMOD
const uint8_t SD_CS_PIN = 44;
#define SPI_CLOCK SD_SCK_MHZ(50) // maximum. Reduce if errors ...
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, DEDICATED_SPI, SPI_CLOCK)
#else
#define SD_CONFIG SdioConfig(FIFO_SDIO) // inbuilt SD on T3,T4
#endif
SdFs sd;
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
flashLED(2);
while (!Serial && millis() < 1000);
Serial << "\n\n------ TEST.b -----\n";
if (!sd.begin(SD_CONFIG)) { sd.initErrorHalt(&Serial); }
else { Serial << F("SD begin OK\n");}
Serial << "---- setup done ---\n";
}
void loop() {
flashLED(1);
delay(1000);
}
void flashLED(int flashes){
for (int i=0; i<flashes; i++){
digitalWrite(LED_BUILTIN,HIGH); delay(100);
digitalWrite(LED_BUILTIN,LOW); delay(100);
}
}