Skip to content

Revert "Use SPI.transfer for spiRec where applicable" #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 5, 2017

Conversation

sandeepmistry
Copy link
Contributor

This reverts commit 2f6748f as suggested by @greiman.

Which should fix arduino/Arduino#5805 and arduino/Arduino#5792.

I did a 10 MB read performance test with the following sketch:

#include <SPI.h>
#include <SD.h>

File myFile;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(115200);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("Initializing SD card...");

  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");

  myFile = SD.open("USS.WAV");

  if (!myFile) {
    // if the file didn't open, print an error:
    Serial.println("error opening file");
    while (1);
  }


  unsigned long start = micros();

  for (int i = 0; i < ((10 * 1024 * 1024) / 512); i++) {
    byte data[512];
    myFile.read(data, sizeof(data));
  }

  unsigned long end = micros();

  Serial.println(end - start);

  myFile.close();
}

void loop() {
}

Results are as follows:

  • v1.0.9: 41594020 microseconds
  • v1.1.0: 41593834 microseconds
  • v1.1.0 + memset of 0xff in spiRec: 41594502 microseconds

so I think the best option is to revert the commit.

cc/ @Fede85 @cmaglie @akash73

@cmaglie cmaglie merged commit 3bbbcbd into arduino-libraries:master Jan 5, 2017
peterpolidoro pushed a commit to janelia-arduino/SD that referenced this pull request Jun 25, 2025
SD.h: Fix -Woverflow for newer compilers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix for 1.80 SD.h
2 participants