2017-05-12 03:49 AM
Hi,
seems that I'm having many problems using the peripherals I need for my MSc Thesis project with the Nucleo-L432KC.
Now it's time to have problems with the microSD card module.
I bought this module:
https://www.amazon.it/gp/product/B01DRT4RU4/ref=oh_aui_detailpage_o00_s00?ie=UTF8&psc=1
I'm using the library SDFileSystem.h from
https://developer.mbed.org/cookbook/SD-Card-File-System
and I tried the example program on my Nucleo-L432KC with these connections:SD card module | Nucleo-L432KC
CS ---> D3 (SPI1_NSS)
SCK ---> A4 (SPI1_SCK)
MOSI ---> A6 (SPI1_MOSI)
MISO ---> A5 (SPI1_MISO)
VCC ---> +3v3
GND ---> GND
I'm using this
https://www.amazon.it/Kingston-SDC4-8GB-MicroSDHC-Adattatore/dp/B001CQT0X4
formatted as FAT32.I got the error message ''Could not open file for write''.
I also tried other connections, using
but I continue getting the same error message.
I tried to create in the SD card the directory and file .txt, used in the example program, before running the program, but it didn't work.
I don't have any other ideas to face and solve this problem, so I would appreciate any kind of help, because I'm going crazy with it!
Thank you all in advance and have a good day!
#nucleo-l432kc #micro-sd-card #sd-card #mbed #sd #stm32l432 #sd-card2017-05-12 04:51 AM
Adapter looks to expect 5V as it has regulator and level shifter. Not sure I'd go that route.
2017-05-12 09:45 AM
,
,
I asked a question on the relative amazon webpage and they answer that the supply is 5 V. I tried connecting VCC to 5V pin but nothing changed: I got the same error message.
Actually this is my program:
♯ include 'mbed.h'
,
♯ include 'SDFileSystem.h'
♯ define BAUDRATE 115200
♯ define MOSI A6
,
♯ define MISO A5
,
♯ define SCLK A4
,
♯ define CS D3
,
SDFileSystem sd(MOSI,MISO,SCLK,CS, 'sd'), // the pinout on the mbed Cool Components workshop board
,
Serial pc(USBTX, USBRX),
int main()
,
{
,
pc.baud(BAUDRATE),
,
wait(5),
,
,
printf('Hello World!\n'),
,
,
mkdir('/sd/mydir', 0777),
,
,
FILE *fp = fopen('/sd/mydir/sdtest.txt', 'w'),
,
if(fp == NULL) {
,
error('Could not open file for write\n'),
,
}
,
fprintf(fp, 'Hello fun SD Card World!'),
,
fclose(fp),
,
,
printf('Goodbye World!\n'),
,
}
I don't know if there's something wrong in this program, but it's basically the example program I referred to, where I added the Serial object pc to make serial communication work and I added the instruction wait(5) to give me the time to open the serial monitor and get the messages.
2017-05-12 11:45 AM
That's all very top level code, it is dependent on a lot of code underneath to make it work, and suitable connectivity.
The sparkfun microsd board makes more sense, though you'd likely want to be sensitive to pull-ups on the pins.
Bit too far off my path for me to wade into.
2017-05-18 05:50 AM
UPDATE:
I tried every release of 'SDFileSystem.h' available on MBED, but nothing worked.I had the suspect that my microSD card module was not working, so I tried the other two I bought, but nothing changed.I tried to use them with an Arduino Due Board using the SD library and I immediately succeeded in writing and reading data from my microSD card, so now I'm sure the modules are working.I tried to use the microSD card module with a Nucleo-F401RE, using
mbed program written and used for a Nucleo-F401RE but the program didn't work at all.I tried to format my microSD card in exFAT and in FAT16, but nothing happened: it continued failing in opening the text file on the microSD card.Please, PLEASE, help me with this situation, I really don't know what to do:(
2017-05-18 08:25 AM
Sounds like the problem lies in the part that mbed hides ('abstracts') from you.
If you can't ensure the hardware works, and the SPI peripheral connection is working properly, the rest becomes pointless.
I would consider either a board supported by mbed and with onboard SD card module, including mbed examples, or scrubbing mbed all together, and go for a C/C++ based development, code examples, and FatFS sources.
2017-05-21 08:58 PM
Those modules are garbage they have buffer from 3.3v to 5v. So they will work with Arduino and most likely won't with any nucleo. My suggestion: get SDIO modules or something on SPI that won't have crappy buffers etc. SDIO is much easier to get running you need around 5 mins to get it working with fatfs.
SPI is harder on stm32 there is a driver in BSP section under adafruit shield if you browse L4 HAL. It's obviously not plug'n play and you need to look at the code.
2018-10-15 11:40 AM
Check https://os.mbed.com/platforms/ST-Nucleo-L432KC/
It is mentioned there:
By default the PA_5 (A4) and PA_6 (A5) pins can only be used as Input floating (ADC function).
Remove SB16 and SB18 solder bridges in order to use these pins as Digital output and have access to other functions (DigitalOut, SPI, PWM, etc...).