Hardware SPI on STM32 with an ILI9341 and microSD card
Connect a TFT and SPI microSD socket to a Blue Pill, then isolate transfer, library and chip-select problems.
Identify the hardware SPI bus
On a standard STM32F103 Blue Pill, SPI1 uses PA5 for SCK, PA6 for MISO and PA7 for MOSI. Wire a shared ground and use the module's stated supply. Confirm 3.3 V compatibility for every data line. Choose an SPI-capable module mode and initialize the instance actually wired to the board.
Give the TFT and microSD socket separate chip-select outputs. The TFT also needs its own D/C line and, if exposed, RESET. Configure both select outputs inactive high before initializing either library. Both peripherals can share SCK and MOSI. A device sharing MISO must release the line while deselected.
Bring up the display and the card separately
First run a display example with its TFT select pin and leave the card deselected. Then run the card-info example with the card select pin and leave the display deselected. On shields and display modules, the socket traces may terminate at separate SD_SCK, SD_MISO and SD_MOSI contacts even though the display already has an SPI header.
If both work individually, use libraries with SPI transaction support so each device can select its SPI speed and mode. A shared-bus failure can also come from a module's level shifter continuing to drive MISO. Test by disconnecting each device's MISO in turn. Use a second hardware SPI bus or a buffer with proper output enable when a module cannot release MISO.
If the build fails, enable verbose compile output and verify which SD, SdFat and ILI9341 libraries were selected. Check their support for your core, the SPI instance parameter and library version. Debug wiring after a known library example builds successfully.
