Skip to main content
antonius
Associate III
September 6, 2013
Question

Question for STM32 USB Full Speed Device Library V2.2.1

  • September 6, 2013
  • 23 replies
  • 2482 views
Posted on September 06, 2013 at 02:11

Hello guys,

I have a question for :

Question for STM32 USB Full Speed Device Library      V2.2.1

How can I use SD card on Mass_storage demos ?

is it connected via SPI or SDIO ? or I can choose ?

and how can I connect my USB to it ? where can I find the configuration for it ?

I have PA11 and PA12 connected to USB port.

Thanks a lot
    This topic has been closed for replies.

    23 replies

    antonius
    antoniusAuthor
    Associate III
    September 9, 2013
    antonius
    antoniusAuthor
    Associate III
    September 9, 2013
    Posted on September 09, 2013 at 16:51

    I can't find CD pin on my SD card, is it optional ? or a must for SDIO ?

    Tesla DeLorean
    Guru
    September 9, 2013
    Posted on September 09, 2013 at 18:06

    I don't see a schematic, looking at the silk-screen suggests SPI, so no

    The CD (Card Detect) is not on the CARD, but the SOCKET, it is a switch actuated by the card when isserted. This SOFTWARE may check this pin, and then not try to initialize/communicate with it. If you don't have the CD, then you'll need to defeat the testing for it.

    I used the following with the STM32F4-Discovery

    http://www.ebay.com.au/itm/MicroSD-Micro-SD-MSD-Card-Breakout-Board-/111078236563?pt=US_Audio_Cables_Adapters&hash=item19dcc76193

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    September 9, 2013
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    antonius
    antoniusAuthor
    Associate III
    September 10, 2013
    Posted on September 10, 2013 at 14:13

    is it possible for me using SPI interface for this demo ? thanks

    or make CD pin as activated always...? it's active high isn't it ?

    Tesla DeLorean
    Guru
    September 10, 2013
    Posted on September 10, 2013 at 15:55

    Hard for me to judge, I think there's enough material there to work with.

    The switch typically makes to ground when the card is inserted, but rather than wire it up one could simply defeat the test within the code.
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    antonius
    antoniusAuthor
    Associate III
    September 11, 2013
    Posted on September 11, 2013 at 17:37

    so just make it CD = 0 in the code then...?

    I just make :

    GPIO_ResetBits(SD_DETECT_GPIO_PORT, SD_DETECT_PIN);    // set pin low

    0690X00000602jXQAQ.jpg

    windows can detect it but can't read the SD yet....any ideas why ?

    thanks

    Tesla DeLorean
    Guru
    September 11, 2013
    Posted on September 11, 2013 at 17:49

    No, defeat the test, for example by not doing it, and always returning SD_PRESENT?

    /**
    * @brief Detect if SD card is correctly plugged in the memory slot.
    * @param None
    * @retval Return if SD is detected or not
    */
    uint8_t SD_Detect(void)
    {
    __IO uint8_t status = SD_PRESENT;
    /*!< Check GPIO to detect SD */
    if (GPIO_ReadInputDataBit(SD_DETECT_GPIO_PORT, SD_DETECT_PIN) != Bit_RESET)
    {
    status = SD_NOT_PRESENT;
    }
    return status;
    }

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    September 12, 2013
    Posted on September 12, 2013 at 13:30

    so just make it CD = 0 in the code then...?

    I just make : GPIO_ResetBits(SD_DETECT_GPIO_PORT, SD_DETECT_PIN); // set pin low

    AGAIN NO, Does that even make the pin low? The pin is in input mode.

    uint8_t SD_Detect(void)
    {
    return SD_PRESENT;
    }

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    antonius
    antoniusAuthor
    Associate III
    September 13, 2013
    Posted on September 13, 2013 at 17:32

    Is it possible for me using SPI interface ?

    I saw :

    /*******************************************************************************

    * Function Name  : SPI_Config

    * Description    : Initializes the SPI1 and CS pins.

    * Input          : None

    * Output         : None

    * Return         : None

    *******************************************************************************/

    void SPI_Config(void)

    {

      GPIO_InitTypeDef  GPIO_InitStructure;

      SPI_InitTypeDef   SPI_InitStructure;

      /* GPIOA and GPIOC Periph clock enable */

      RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC, ENABLE);

      /* SPI1 Periph clock enable */

      RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);

      /* Configure SPI1 pins: SCK, MISO and MOSI */

      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7;

      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;

      GPIO_Init(GPIOA, &GPIO_InitStructure);

      /* Configure PC12 pin: CS pin */

      GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12;

      GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

      GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;

      GPIO_Init(GPIOC, &GPIO_InitStructure);

      /* SPI1 Config */

      SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;

      SPI_InitStructure.SPI_Mode = SPI_Mode_Master;

      SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;

      SPI_InitStructure.SPI_CPOL = SPI_CPOL_High;

      SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;

      SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;

      SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_4;

      SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;

      SPI_InitStructure.SPI_CRCPolynomial = 7;

      SPI_Init(SPI1, &SPI_InitStructure);

      /* SPI1 enable */

      SPI_Cmd(SPI1, ENABLE);

    }

    on UM0424\USBLib\Demos\Mass_Storage\Project\RVMDK\.....\msd.c