SDFileSystem.cpp has got a wrong code. SD Card dosent work due to wrong SPI freq. NUCLEO L476RG

06 Mar 2017

Hi,

SDFileSystem.cpp line 122 ..

#include "SDFileSystem.h"
#include "mbed_debug.h"

#define SD_COMMAND_TIMEOUT 5000

#define SD_DBG             0

SDFileSystem::SDFileSystem(PinName mosi, PinName miso, PinName sclk, PinName cs, const char* name) :
    FATFileSystem(name), _spi(mosi, miso, sclk), _cs(cs), _is_initialized(0) {
    _cs = 1;

    // Set default to 100kHz for initialisation and 1MHz for data transfer
    _init_sck = 100000;
    _transfer_sck = 1000000;
}


The above part cause the following error on the terminal.

Terminal output

Couldn't set suitable spi freq: request:100000, lowest:156250

IT is obvious that the min freq. should be at least 156250 for my NUCLEO L476RG. Shouldn't this line be calculating the correct min frequency Independent to the MCU frequency? Why is this hard coded? thanks

13 Mar 2018

same problem but on a stm32f767zi ...

"Couldn't set suitable spi freq: request:100000, lowest:421875"

18 Mar 2018

Same problem on a NUCLEO STM32F446

Couldn't set suitable spi freq: request:100000, lowest:175781

27 Mar 2018

I am also having this problem on STM32 Nucleo-144 development board with STM32F429ZIT6 MCU. Couldn't set suitable spi freq: request:100000, lowest:328125

03 Apr 2018

Hello All,

I have raised an issue in SD driver repo to have configurable frequency. Please see https://github.com/ARMmbed/sd-driver/issues/89 for further updates.

Regards, Deepika

16 Apr 2018

For the nucleo F103rb , i was facing a similar issue. The sd write function works just by changing the _init_sck macro in the SDFilesystem.cpp file by the frequency mentioned macro.

19 Jun 2018

Thank you Deepika Bhavnani . You fixed the problem.