SD-Card Reader problem
-
- Posts: 8
- Joined: Mon Jan 18, 2021 11:01 am
SD-Card Reader problem
Hi all,
i got a Mable Mini Clone and want to build a MIDI-Controller. This is my first use of a 32F103 and anything works perfect, multiplexing encoders and potentiometers i connected a LCD Display but i can not get the SD-Card reader board with SPI Interface to work.
I used the Arduino SD-Example as written in the Arduino forum and also here but it dont work.
I tried SPI1, SPI2, and SPI3 but nothing works i also mapped the Pins with SPI.setMOSI(Pin) but it dont work as i read in the Forum. Is there another way to get it work? I think it is a Chip Select problem but how i can fix it?
Arduino IDE 1.8.13 installed, latest STM32duino core and roger clarks arduino STM32 for Maple Mini
Thanks
i got a Mable Mini Clone and want to build a MIDI-Controller. This is my first use of a 32F103 and anything works perfect, multiplexing encoders and potentiometers i connected a LCD Display but i can not get the SD-Card reader board with SPI Interface to work.
I used the Arduino SD-Example as written in the Arduino forum and also here but it dont work.
I tried SPI1, SPI2, and SPI3 but nothing works i also mapped the Pins with SPI.setMOSI(Pin) but it dont work as i read in the Forum. Is there another way to get it work? I think it is a Chip Select problem but how i can fix it?
Arduino IDE 1.8.13 installed, latest STM32duino core and roger clarks arduino STM32 for Maple Mini
Thanks
Re: SD-Card Reader problem
well hard to tell.
You should use the default SPI pins as described in the variant.
and by default the CS pin is defined by the example.
You should use the default SPI pins as described in the variant.
Code: Select all
#define PIN_SPI_MOSI PA7
#define PIN_SPI_MISO PA6
#define PIN_SPI_SCK PA5
-
- Posts: 8
- Joined: Mon Jan 18, 2021 11:01 am
Re: SD-Card Reader problem
Wow,
Thank you very much. It is so easy.......
Why i didnt found that?
Can i use another SPI Port also? How i configure SPI2 Port?
It now works also with the SDFat Example......
Thanks
Thank you very much. It is so easy.......
Why i didnt found that?
Can i use another SPI Port also? How i configure SPI2 Port?
It now works also with the SDFat Example......
Thanks
-
- Posts: 8
- Joined: Mon Jan 18, 2021 11:01 am
Re: SD-Card Reader problem
Thank you,
this is also what i found but i dont understand it. If i map the Pins with SPI.setMOSI(PC2); i got a error message from the Compiler:
SPI does not name a type
I also tried to use:
Dont work. Why i can not only change the Pins, need it to initalize the second SPI?
In the SD Example CardInfo they never call SPI.begin(), so where i can find it?
Thanks
Ok. I got it.
I used
to remap the SPI Pins. It remaps automaticly SPI1 to SPI2. You only have to define the CS Pin in the Sketch.
Thanks
this is also what i found but i dont understand it. If i map the Pins with SPI.setMOSI(PC2); i got a error message from the Compiler:
SPI does not name a type
I also tried to use:
Code: Select all
#define PIN_SPI_MOSI PB15 //SPI2
#define PIN_SPI_MISO PB14 //SPI2
#define PIN_SPI_SCK PB13 //SPI2
In the SD Example CardInfo they never call SPI.begin(), so where i can find it?
Thanks
Ok. I got it.
I used
Code: Select all
SPI.setModule(2);
Thanks
Last edited by mannitb303 on Mon Jan 18, 2021 5:23 pm, edited 1 time in total.
Re: SD-Card Reader problem
SPI.begin() is hidden in the library.
There is no PC2 defined for maple that's why you get error... compiler has alwaysthe right answers
On Maple, SPI2 peripheral can be found on PB13(SCLK), PB14(MISO) and PB15(MOSI).
So you can use setXXX() before the call of SPI.begin() or define a new instance but several thied party libraries hardcode the default 'SPI' instance.
There is no PC2 defined for maple that's why you get error... compiler has alwaysthe right answers

On Maple, SPI2 peripheral can be found on PB13(SCLK), PB14(MISO) and PB15(MOSI).
So you can use setXXX() before the call of SPI.begin() or define a new instance but several thied party libraries hardcode the default 'SPI' instance.
Code: Select all
SPIClass SPI_2(PB15, PB14, PB13);
-
- Posts: 8
- Joined: Mon Jan 18, 2021 11:01 am
Re: SD-Card Reader problem
Sorry,
i dont change the PC2 Pin in the SPI.setMOSI. But if i change it to PB15 i got the same error from my Compiler. SPI does not name a type.
If i try
i got also a error from my Compiler.
it works.
Thank you.
i dont change the PC2 Pin in the SPI.setMOSI. But if i change it to PB15 i got the same error from my Compiler. SPI does not name a type.
If i try
Code: Select all
SPIClass SPI_2(PB15, PB14, PB13);
- CardInfo:37:32: error: no matching function for call to 'SPIClass::SPIClass(<anonymous enum>, <anonymous enum>, <anonymous enum>)'
SPIClass SPI_2(PB15, PB14, PB13);
^
C:\Users\smanh\AppData\Local\Temp\arduino_modified_sketch_958854\CardInfo.ino:37:32: note: candidates are:
In file included from C:\Users\smanh\AppData\Local\Temp\arduino_modified_sketch_958854\CardInfo.ino:23:0:
C:\Users\smanh\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2020.12.26\libraries\SPI\src/SPI.h:176:5: note: SPIClass::SPIClass(uint32)
SPIClass(uint32 spiPortNumber);
^
C:\Users\smanh\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2020.12.26\libraries\SPI\src/SPI.h:176:5: note: candidate expects 1 argument, 3 provided
C:\Users\smanh\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2020.12.26\libraries\SPI\src/SPI.h:170:7: note: constexpr SPIClass::SPIClass(const SPIClass&)
class SPIClass {
^
C:\Users\smanh\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2020.12.26\libraries\SPI\src/SPI.h:170:7: note: candidate expects 1 argument, 3 provided
C:\Users\smanh\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2020.12.26\libraries\SPI\src/SPI.h:170:7: note: constexpr SPIClass::SPIClass(SPIClass&&)
C:\Users\smanh\AppData\Local\Arduino15\packages\stm32duino\hardware\STM32F1\2020.12.26\libraries\SPI\src/SPI.h:170:7: note: candidate expects 1 argument, 3 provided
exit status 1
no matching function for call to 'SPIClass::SPIClass(<anonymous enum>, <anonymous enum>, <anonymous enum>)'
Code: Select all
SPI.setModule(2)
Thank you.
Re: SD-Card Reader problem
So you use Rogers (libmaple) core not STM32 core....
-
- Posts: 8
- Joined: Mon Jan 18, 2021 11:01 am
Re: SD-Card Reader problem
I installed both... Can this be the problem?
Re: SD-Card Reader problem
No. You can use both. They are independent. But they do not have the same API. So be precise next time. My previous post are valid for STM32 core not maple one.