This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

STM32 SD/MMC SPI problem

Hi,
I change File System Demo Example from SDIO to SPI but don't work!Please help me.
I want to use SD/MMC for STM32F103C8.
Regards
AliReza

Parents
  • Thanks for your reply,
    I use my board(stm32f103c8) and connect SD to SPI2. I changed FS_Config_MC_0.h to this:

    // <h>Memory Card Drive 0
    // Configuration for SD/SDHC/MMC Memory Card assigned to drive letter "M0:"
    #define MC0_ENABLE 1

    // <o>Connect to hardware via Driver_MCI# <0-255>
    // Select driver control block for hardware interface
    #define MC0_MCI_DRIVER 0

    // <o>Connect to hardware via Driver_SPI# <0-255>
    // Select driver control block for hardware interface when in SPI mode
    #define MC0_SPI_DRIVER 2

    // <o>Memory Card Interface Mode <0=>Native <1=>SPI
    // Native uses a SD Bus with up to 8 data lines, CLK, and CMD
    // SPI uses 2 data lines (MOSI and MISO), SCLK and CS
    #define MC0_SPI 1

    and RTE_Device.h:

    // <e> SPI2 (Serial Peripheral Interface 2) [Driver_SPI2]
    // Configuration settings for Driver_SPI2 in component ::CMSIS Driver:SPI
    #define RTE_SPI2 1

    // <e> SPI2_NSS Pin
    // Configure Pin if exists
    // GPIO Pxy (x = A..G, y = 0..15)
    // <o1> Port <0=>GPIOA <1=>GPIOB <2=>GPIOC <3=>GPIOD
    // <4=>GPIOE <5=>GPIOF <6=>GPIOG
    // Selects Port Name
    // <o2> Bit <0-15>
    // Selects Port Bit
    // </e>
    #define RTE_SPI2_NSS_PIN 1
    #define RTE_SPI2_NSS_PORT GPIO_PORT(1)
    #define RTE_SPI2_NSS_BIT 12

    // <o> SPI2_SCK Pin <0=>PB13
    #define RTE_SPI2_SCK_PORT_ID 0
    #if (RTE_SPI2_SCK_PORT_ID == 0)
    #define RTE_SPI2_SCK_PORT GPIOB
    #define RTE_SPI2_SCK_BIT 13
    #define RTE_SPI2_SCK_REMAP 0
    #else
    #error "Invalid SPI2_SCK Pin Configuration!"
    #endif

    // <o> SPI2_MISO Pin <0=>Not Used <1=>PB14
    #define RTE_SPI2_MISO_PORT_ID 1
    #if (RTE_SPI2_MISO_PORT_ID == 0)
    #define RTE_SPI2_MISO 0
    #elif (RTE_SPI2_MISO_PORT_ID == 1)
    #define RTE_SPI2_MISO 1
    #define RTE_SPI2_MISO_PORT GPIOB
    #define RTE_SPI2_MISO_BIT 14
    #define RTE_SPI2_MISO_REMAP 0
    #else
    #error "Invalid SPI2_MISO Pin Configuration!"
    #endif

    // <o> SPI2_MOSI Pin <0=>Not Used <1=>PB15
    #define RTE_SPI2_MOSI_PORT_ID 1
    #if (RTE_SPI2_MOSI_PORT_ID == 0)
    #define RTE_SPI2_MOSI 0
    #elif (RTE_SPI2_MOSI_PORT_ID == 1)
    #define RTE_SPI2_MOSI 1
    #define RTE_SPI2_MOSI_PORT GPIOB
    #define RTE_SPI2_MOSI_BIT 15
    #define RTE_SPI2_MOSI_REMAP 0
    #else
    #error "Invalid SPI2_MISO Pin Configuration!"
    #endif

Reply
  • Thanks for your reply,
    I use my board(stm32f103c8) and connect SD to SPI2. I changed FS_Config_MC_0.h to this:

    // <h>Memory Card Drive 0
    // Configuration for SD/SDHC/MMC Memory Card assigned to drive letter "M0:"
    #define MC0_ENABLE 1

    // <o>Connect to hardware via Driver_MCI# <0-255>
    // Select driver control block for hardware interface
    #define MC0_MCI_DRIVER 0

    // <o>Connect to hardware via Driver_SPI# <0-255>
    // Select driver control block for hardware interface when in SPI mode
    #define MC0_SPI_DRIVER 2

    // <o>Memory Card Interface Mode <0=>Native <1=>SPI
    // Native uses a SD Bus with up to 8 data lines, CLK, and CMD
    // SPI uses 2 data lines (MOSI and MISO), SCLK and CS
    #define MC0_SPI 1

    and RTE_Device.h:

    // <e> SPI2 (Serial Peripheral Interface 2) [Driver_SPI2]
    // Configuration settings for Driver_SPI2 in component ::CMSIS Driver:SPI
    #define RTE_SPI2 1

    // <e> SPI2_NSS Pin
    // Configure Pin if exists
    // GPIO Pxy (x = A..G, y = 0..15)
    // <o1> Port <0=>GPIOA <1=>GPIOB <2=>GPIOC <3=>GPIOD
    // <4=>GPIOE <5=>GPIOF <6=>GPIOG
    // Selects Port Name
    // <o2> Bit <0-15>
    // Selects Port Bit
    // </e>
    #define RTE_SPI2_NSS_PIN 1
    #define RTE_SPI2_NSS_PORT GPIO_PORT(1)
    #define RTE_SPI2_NSS_BIT 12

    // <o> SPI2_SCK Pin <0=>PB13
    #define RTE_SPI2_SCK_PORT_ID 0
    #if (RTE_SPI2_SCK_PORT_ID == 0)
    #define RTE_SPI2_SCK_PORT GPIOB
    #define RTE_SPI2_SCK_BIT 13
    #define RTE_SPI2_SCK_REMAP 0
    #else
    #error "Invalid SPI2_SCK Pin Configuration!"
    #endif

    // <o> SPI2_MISO Pin <0=>Not Used <1=>PB14
    #define RTE_SPI2_MISO_PORT_ID 1
    #if (RTE_SPI2_MISO_PORT_ID == 0)
    #define RTE_SPI2_MISO 0
    #elif (RTE_SPI2_MISO_PORT_ID == 1)
    #define RTE_SPI2_MISO 1
    #define RTE_SPI2_MISO_PORT GPIOB
    #define RTE_SPI2_MISO_BIT 14
    #define RTE_SPI2_MISO_REMAP 0
    #else
    #error "Invalid SPI2_MISO Pin Configuration!"
    #endif

    // <o> SPI2_MOSI Pin <0=>Not Used <1=>PB15
    #define RTE_SPI2_MOSI_PORT_ID 1
    #if (RTE_SPI2_MOSI_PORT_ID == 0)
    #define RTE_SPI2_MOSI 0
    #elif (RTE_SPI2_MOSI_PORT_ID == 1)
    #define RTE_SPI2_MOSI 1
    #define RTE_SPI2_MOSI_PORT GPIOB
    #define RTE_SPI2_MOSI_BIT 15
    #define RTE_SPI2_MOSI_REMAP 0
    #else
    #error "Invalid SPI2_MISO Pin Configuration!"
    #endif

Children