2013-09-05 05:11 PM
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 lot2013-09-05 07:00 PM
May be 3.4.0 or 4.0.0 would be more appropriate, pick an EVAL board that approximates your board most closely. Mimic that, adjust/port as required.
STM32_USB-FS-Device_Lib_V4.0.0\Utilities\STM32_EVAL\STM3210E_EVAL\stm3210e_eval_sdio_sd.c STM32_USB-FS-Device_Lib_V4.0.0\Utilities\STM32_EVAL\STM3210B_EVAL\stm3210b_eval_spi_sd.c STM32_USB-FS-Device_Lib_V4.0.0\Projects\Mass_Storage2013-09-06 02:48 PM
2013-09-06 04:09 PM
How can I choose it ? or automatically detect which interface I used ?
You should take a look at the project files, the method to select a particular board is usually driven by a define passed into the compiler, and a board appropriate interface is selected. Some F10x parts don't support SDIO, hence the SPI method. It would likely be possible to support multiple interfaces, but you'd have to deal with that and LUN support via MSC/SCSI. I would generally steer clear of SPI as it's hideously slow. Clone one of the board support packages under Utilities, and add in the #ifdef customization as required, or just cull the project down for your board, removing LCD and LED support as needed. For SDIO review the schematics, be sure to use 33-47K pull-up on the lines close to the socket. Most of the pins you have no choice over, but the Card Detect can be any convenient GPIO.
2013-09-06 06:08 PM
Window can detect the reader as USB mass storage, but can't detect the card yet...
I used this configuration for connecting the board to card module Is it right ? /** * @brief Initializes the SD Card and put it into StandBy State (Ready for * data transfer). * @param None * @retval None */ void SD_LowLevel_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; /*!< GPIOC and GPIOD Periph clock enable */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | SD_DETECT_GPIO_CLK, ENABLE); /*!< Configure PC.08, PC.09, PC.10, PC.11, PC.12 pin: D0, D1, D2, D3, CLK pin */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOC, &GPIO_InitStructure); /*!< Configure PD.02 CMD line */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_Init(GPIOD, &GPIO_InitStructure); /*!< Configure SD_CD pin: SD Card detect pin */ GPIO_InitStructure.GPIO_Pin = SD_DETECT_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_InitStructure); /*!< Enable the SDIO AHB Clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_SDIO, ENABLE); /*!< Enable the DMA2 Clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE); }2013-09-06 06:18 PM
do you have the link for downloading it ?thanks
2013-09-06 07:38 PM
[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32%20Legacy%20Firmware%20Libraries&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/AllItems.aspx¤tviews=5209]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fSTM32%20Legacy%20Firmware%20Libraries&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&TopicsView=https%3A%2F%2Fmy.st.com%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FAllItems.aspx¤tviews=5209
http://www.st.com/web/catalog/tools/FM147/CL1794/SC961/SS1743/PF258157
2013-09-07 10:53 PM
Here's the connection to the card,
Please correct me if I'm wrong STM32 --> SD card PC8 ---> pin7 PC9 ---> pin8 PC10 ---> pin9 PC11 ---> pin5 PD2 ---> pin2 This is the configuration I used /** * @brief Initializes the SD Card and put it into StandBy State (Ready for * data transfer). * @param None * @retval None */ void SD_LowLevel_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; /*!< GPIOC and GPIOD Periph clock enable */ RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | SD_DETECT_GPIO_CLK, ENABLE); /*!< Configure PC.08, PC.09, PC.10, PC.11, PC.12 pin: D0, D1, D2, D3, CLK pin */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9 | GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOC, &GPIO_InitStructure); /*!< Configure PD.02 CMD line */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2; GPIO_Init(GPIOD, &GPIO_InitStructure); /*!< Configure SD_CD pin: SD Card detect pin */ GPIO_InitStructure.GPIO_Pin = SD_DETECT_PIN; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; GPIO_Init(SD_DETECT_GPIO_PORT, &GPIO_InitStructure); /*!< Enable the SDIO AHB Clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_SDIO, ENABLE); /*!< Enable the DMA2 Clock */ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA2, ENABLE); } it's on SDIO_SD.c2013-09-08 05:13 AM
Where's PC12 go? What about the card detect switch?
This is a schematic of a card configuration, I'd be using pull-ups for all but the clock pins Personally I use MicroSD cards, they run faster, but ST's code works on 2GB and lower cards better.2013-09-08 05:33 AM
Let me correct it :
STM32 --> SD card PC8 ---> pin7 PC9 ---> pin8 PC10 ---> pin9 PC11 ---> pin1 PC12 -->pin5 PD2 ---> pin2 Please correct me if I'm wrong thank you