From a3a42ad011eff3516eed374eef8cfcf647493347 Mon Sep 17 00:00:00 2001 From: gvl610 Date: Wed, 25 Oct 2023 23:54:47 +0700 Subject: [PATCH] Increase SPI speed to fCLk/2 after SD card init --- sdcard.c | 2 ++ sdcard.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/sdcard.c b/sdcard.c index fbd7cad..10cf3c5 100644 --- a/sdcard.c +++ b/sdcard.c @@ -61,6 +61,8 @@ uint8_t SD_init() SD_readOCR(res); + SPI_init(SPI_MASTER | SPI_2X_FOSC_2 | SPI_MODE_0); + return SD_SUCCESS; } diff --git a/sdcard.h b/sdcard.h index eb6e418..3d9bcee 100644 --- a/sdcard.h +++ b/sdcard.h @@ -42,7 +42,7 @@ #define CMD55_MAX_ATTEMPTS 255 #define SD_ERROR 1 #define SD_SUCCESS 0 -#define SD_MAX_READ_ATTEMPTS 1563 +#define SD_MAX_READ_ATTEMPTS 3907 #define SD_READ_START_TOKEN 0xFE #define SD_INIT_CYCLES 80