SD-Card Reader problem

Maple Mini, Maple Rev3, Maple Rev 5 and Maple Ret 6, iTead Maple etc
mannitb303
Posts: 8
Joined: Mon Jan 18, 2021 11:01 am

SD-Card Reader problem

Post by mannitb303 »

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
User avatar
fpiSTM
Posts: 975
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 44
Location: Le Mans
Contact:

Re: SD-Card Reader problem

Post by fpiSTM »

well hard to tell.
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
and by default the CS pin is defined by the example.
mannitb303
Posts: 8
Joined: Mon Jan 18, 2021 11:01 am

Re: SD-Card Reader problem

Post by mannitb303 »

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
User avatar
fpiSTM
Posts: 975
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 44
Location: Le Mans
Contact:

Re: SD-Card Reader problem

Post by fpiSTM »

mannitb303
Posts: 8
Joined: Mon Jan 18, 2021 11:01 am

Re: SD-Card Reader problem

Post by mannitb303 »

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:

Code: Select all

#define PIN_SPI_MOSI            PB15  //SPI2
#define PIN_SPI_MISO            PB14  //SPI2
#define PIN_SPI_SCK             PB13  //SPI2
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

Code: Select all

SPI.setModule(2);
to remap the SPI Pins. It remaps automaticly SPI1 to SPI2. You only have to define the CS Pin in the Sketch.

Thanks
Last edited by mannitb303 on Mon Jan 18, 2021 5:23 pm, edited 1 time in total.
User avatar
fpiSTM
Posts: 975
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 44
Location: Le Mans
Contact:

Re: SD-Card Reader problem

Post by fpiSTM »

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 :mrgreen:
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);
mannitb303
Posts: 8
Joined: Mon Jan 18, 2021 11:01 am

Re: SD-Card Reader problem

Post by mannitb303 »

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

Code: Select all

SPIClass SPI_2(PB15, PB14, PB13);
i got also a error from my Compiler.
  • 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>)'
But now with

Code: Select all

SPI.setModule(2)
it works.

Thank you.
User avatar
fpiSTM
Posts: 975
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 44
Location: Le Mans
Contact:

Re: SD-Card Reader problem

Post by fpiSTM »

So you use Rogers (libmaple) core not STM32 core....
mannitb303
Posts: 8
Joined: Mon Jan 18, 2021 11:01 am

Re: SD-Card Reader problem

Post by mannitb303 »

I installed both... Can this be the problem?
User avatar
fpiSTM
Posts: 975
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 44
Location: Le Mans
Contact:

Re: SD-Card Reader problem

Post by fpiSTM »

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.
Post Reply

Return to “Maple & Maple mini etc”