SPI.end() hangs on maple mini

Post here first, or if you can't find a relevant section!
Post Reply
pykowiec
Posts: 2
Joined: Tue Mar 12, 2024 9:53 pm

SPI.end() hangs on maple mini

Post by pykowiec »

Hi,

After using libmaple for several years, I decided to move my project to the stm32duino libraries. I have to use an NRF24 radio connected to SPI2 and have SPI1 disabled. I can't connect the radio module to SPI1 because I use SPI1 pins other purposes. So I need to deactivate SPI1. After calling SPI.end(), the program hangs.
I also tried removing the SPI declaration of the SPIclass from the SPI.c file, but this had no effect. SPI port 1 is still active.

My board is Maple Mini with SPI1 on pins 4, 5, 6, 7, STM ports PA7, PA6, PA5, PA4.

Any ideas on how to disable SPI1?
User avatar
fpiSTM
Posts: 1738
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 91
Location: Le Mans
Contact:

Re: SPI.end() hangs on maple mini

Post by fpiSTM »

By default, the SPI instance is mapped to the SPI1, anyway, it is easy to override it to use the SPI2 and linked pins.
You can read the wiki:
https://github.com/stm32duino/Arduino_C ... tance-pins

So first way is simply to change pins at runtime:

Code: Select all

    SPI.setMISO(PB14);
    SPI.setMOSI(PB15);
    SPI.setSCLK(PB13);
    SPI.begin();
Other way is simply to change the default pins defined in the variant so it will act at build time
https://github.com/stm32duino/Arduino_C ... h#L95-L107

You can use build_opt.h: https://github.com/stm32duino/Arduino_C ... uild_opt.h

Code: Select all

-DPIN_SPI_MOSI=PB15 -DPIN_SPI_MISO=PB14 -DPIN_SPI_SCK=PB13
pykowiec
Posts: 2
Joined: Tue Mar 12, 2024 9:53 pm

Re: SPI.end() hangs on maple mini

Post by pykowiec »

Thanks for the help. I have tried all the methods you mentioned above. Works great in the sense of activating SPI on pot 2. NRF24 attached to the SPI2 pin works fine.

There is still a problem with pins PA4, PA5, PA6 and PA7. It is not possible to use them as an analog input or digital output. It looks like they are still blocked by SPI1.
Post Reply

Return to “General discussion”