Comments (10)
0x17, 0xFF is the basic initialization command which occurs at very low SPI clock. Usually means an SPI problem.
Is the SD connected to the correct pins?
Are you trying to map the SPI pins?
from sdfat.
Hi, thanks for your help. I believe the SPI interface is connected correctly, as if I change it at all then I get 0x01, with the SPI failing completely. I am using SPI.begin to set the SPI bus to the pins I am using. My code roughly goes as follows
#define SD_FAT_TYPE 0
SdFat sd;
void setup() {
SPI.begin(SD_SCK, SD_MISO, SD_MOSI, -1);
if(!sd.begin(SD_CS)) {
sd.initErrorHalt();
}
}
from sdfat.
You need to prevent SdFat from calling SPI.begin().
#define SD_FAT_TYPE 0 // Will platformio make this global??
// You can use DEDICATE_SPI in place of SHARE_SPI if the SD is the only SPI device.
// Choose a higher SD_SCK after you test this.
#define SD_CONFIG SdSpiConfig(SD_CS, USER_SPI_BEGIN | SHARED_SPI, SD_SCK_MHZ(10))
SdFat sd;
void setup() {
SPI.begin(SD_SCK, SD_MISO, SD_MOSI, -1);
if(!sd.begin(SD_CONFIG)) {
sd.initErrorHalt();
}
}
void loop() {}
from sdfat.
Ok, I will try that later today when I am able.
from sdfat.
It didn't work. I am still getting 0x17. My exact code is
#include <Arduino.h>
#include <SPI.h>
#include "SdFat.h"
#define SD_FAT_TYPE 0
const uint8_t SD_CS_PIN = 6;
const uint8_t SD_MISO_PIN = 10;
const uint8_t SD_MOSI_PIN = 9;
const uint8_t SD_SCK_PIN = 11;
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, USER_SPI_BEGIN | DEDICATED_SPI, SD_SCK_MHZ(10))
#if SD_FAT_TYPE == 0
SdFat sd;
#elif SD_FAT_TYPE == 1
SdFat32 sd;
#elif SD_FAT_TYPE == 2
SdExFat sd;
#elif SD_FAT_TYPE == 3
SdFs sd;
#else
#error Invalid SD_FAT_TYPE
#endif
void setup() {
Serial.begin(115200);
Serial.println("Type any character to start");
while(!Serial.available()) {
yield();
}
SPI.begin(SD_SCK_PIN, SD_MISO_PIN, SD_MOSI_PIN, -1);
if(!sd.begin(SD_CONFIG)) {
sd.initErrorHalt();
}
}
void loop() {
}
And console output
Type any character to start
begin() failed
Do not reformat the SD.
SdError: 0X17,0XFF
I also tried moving the #define SD_FAT_TYPE 0
into the beginning of SdFat.h, and it had no effect, so I believe that it takes global effect.
from sdfat.
I can't do more since I don't have your hardware.
Here is a similar ESP32 issue where the above worked.
from sdfat.
OK, thank you for your efforts. If I can't get it to work, I might just have to bit-bang it.
from sdfat.
You need to verify the SPI is available on the pins you selected. Here is a pinout for Feather ESP32-S3:
Looks like the option is:
MOSI pin 11
SCK pin 12
MISO pin 13
Standard pins are:
SCK pin 36
MOSI pin 35
MISO pin 37
from sdfat.
Here is the IO MUX pin functions from the ESP32-S3 datasheet:
from sdfat.
I found a ESP32-S2 Feather someone gave me. It has the same pinout as the ESP32-S3 Feather.
I edited your sketch to use the correct pins and added a call to ls().
#include <Arduino.h>
#include <SPI.h>
#include "SdFat.h"
#define SD_FAT_TYPE 0
const uint8_t SD_CS_PIN = 10;
const uint8_t SD_MISO_PIN = 13;
const uint8_t SD_MOSI_PIN = 11;
const uint8_t SD_SCK_PIN = 12;
#define SD_CONFIG SdSpiConfig(SD_CS_PIN, USER_SPI_BEGIN | DEDICATED_SPI, SD_SCK_MHZ(10))
#if SD_FAT_TYPE == 0
SdFat sd;
#elif SD_FAT_TYPE == 1
SdFat32 sd;
#elif SD_FAT_TYPE == 2
SdExFat sd;
#elif SD_FAT_TYPE == 3
SdFs sd;
#else
#error Invalid SD_FAT_TYPE
#endif
void setup() {
Serial.begin(115200);
Serial.println("Type any character to start");
while(!Serial.available()) {
yield();
}
SPI.begin(SD_SCK_PIN, SD_MISO_PIN, SD_MOSI_PIN, -1);
if(!sd.begin(SD_CONFIG)) {
sd.initErrorHalt();
}
sd.ls();
}
void loop() {}
Here is the output:
bench.dat
SF411Logger.csv
STM32F411Logger.csv
STM32F411ADC/
STM32F411Logger/
from sdfat.
Related Issues (20)
- ExFatLogger vs LowLatencyLogger different behaviour HOT 7
- Running two SdCards are not working HOT 2
- addApbChangeCallback(): duplicate func when using with TFT_eSPI HOT 5
- Problems with Teensy 4.0 and Adafruit XTSD with SdFat. HOT 2
- [question]How to speed up sd writes on Arduino Uno r4? HOT 7
- Examples of SDFat HOT 4
- sdfat does one write to sd and then nothing HOT 1
- SdFat recommended usage for long term data logging HOT 5
- Pin selection for esp8266 HOT 1
- Did not work at ESP32-CAM HOT 6
- MMC_ERASE HOT 2
- Wrapper to fs::FS to use SDfat in ESPAsyncWebserver HOT 6
- pico-sdk only rp2040 implementation HOT 7
- Unable to format flat Spiflash module with ESP8266 HOT 4
- Mount issues for a Windows-formatted card HOT 35
- SD NAND XTSD01G (surface mounted chip) not formating HOT 1
- Unable to share the same SPI bus with TFT_eSPI on ESP32 HOT 1
- Problems with multiple SD card HOT 3
- Long timeout calling begin() on Teensy 4.1 when no card present HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sdfat.