MKRZERO 2 SPI's open uses too much current

I have a MKRZERO. Using LowPower.sleep(); gives 0.5mA with either ADXL via SPI or SDcard enabled.

When BOTH SD.begin(); and SPI.begin() is used the current jumps to 14mA.

The chip selects are different. The schematic shows it as a different port.

Got a bit lost on the explanation of making a new SPI port bu t don’t believe that is required for the MKRZERO. Creating a new SPI | Using ATSAMD21 SERCOM for more SPI, I2C and Serial ports | Adafruit Learning System

Simplified code attached that generates the issue.

I changed to SPI from I2C on the ADXL after two weeks of intermittent crashes in field testing.

Any suggestion most welcome.

SOLUTION FOUND: use SdFat.h and SD chip select = HIGH before sleep.

MKRZERO SD_CS = 28

so in code

const int SD_CS = SDCARD_SS_PIN; // pin 28;
const int SD_MOSI = SDCARD_MOSI_PIN; // pin 27; //refer to variant.h for more information
const int SD_MISO = SDCARD_MISO_PIN; // pin 29;
const int SD_SCK = SDCARD_SCK_PIN; // pin 26;

pinMode(SD_CS, OUTPUT);
pinMode(SD_MOSI, OUTPUT);
pinMode(SD_MISO, INPUT_PULLDOWN);
pinMode(SD_SCK, OUTPUT);

arduino_Forum_SD_ADXL_current_issue.ino (5.22 KB)

added notes

1/ did the pinMode and write HIGH trick from

… current goes to 12mA when SPI.end(); is used just before LowPower.sleep();

2/ tried a Sandisk SD Card - did not work (actually went to 21mA) - did not work

3/ removing each SPI line from the ADXL does not effect the current - conclusion, no conflict between SPI
SD and SPI external

4/ removing the SD card reduces the current to 0.39 mA.

5/ Using SdFat.h …
all currents are given after USB is removed and MKRZERO is reset
5.1 not writing CS, SCK or MOSI HIGH gives = 0.81mA
5.1 writing CS, SCK, MOSI = HIGH gives = 0.43 reset on battery only (1.11mA just after USB out)
5.2 writing CS, SCK, MOSI = LOW gives = 0.56 mA
5.3 writing CS = HIGH, SCK, MOSI = LOW = 0.43 mA
5.4 writing to just CS = HIGH = 0.43mA

so all CS = HIGH gives best results. SCK and MOSI are “dont care” … for this SD card. so I will write to all 3 pins to be safe.