2012-04-17 09:58 PM
I have an obvious question :
How do I implement SDCard as MassStorage on the Stm32f4Discovery Board ? Why is there Examples of this for the stm32F103 but not for the stm32F4discovery ? The wonderful 22examples for the Discovery are a lot less than the stm32f103 examples present. It seems like it should be a simple modifying of code. But, I find no examples or support for this anywhere at Stm or on the internet (besides my site). Has Anybody tried this Project yet ? #stm32f4discovery #stm3240g #epic-fail #msc2012-06-21 03:02 PM
Attached is am initial correction to the MSC library code for the F2, for the F4 you'll want to pull out the SD_ReadMultiBlocksFIXED() and SD_WriteMultiBlocksFIXED() into the stm324xg_eval_sdio.c & .h files (or whatever they are called). Should just be a cut-n-paste operation.
I've basically moved from a BYTE orientated addressing to BLOCK orientated addressing so the offset into the flash device doesn't exceed the 32-bit / 4GB bounds. I also addresses so unnecessary casting between 16-32-16 bit to avoid any potential future loss of precision. I've done some early testing of this, will do some more. If the forum crashed in the future and eats this attachment, or you need to discuss it off-board, my address is sourcer32@gmail.com ________________ Attachments : patched_4gb_msc.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0ZD&d=%2Fa%2F0X0000000baU%2FZejudsZTfY6vLnVvip_SPwLDmrkmI.NxsbH4GP9WJKI&asPdf=false2012-06-25 11:21 AM
Attached is a complete STM32F4-Discovery project for SDHC Cards via USB Mass Storage (MSC)
The SD Slot/Socket is expected to be wired as follows CARDDETECT = PC2 (Retargetable) CLK = PC12 CMD = PD2 D0 = PC8 D1 = PC9 D2 = PC10 D3 = PC11 VDD = 3V VSS = GND PC10 (SCLK) and PC12 (SDIN) potentially conflict with the CS43L22 This builds with GNU/GCC 4.6.2 or 4.7.1 ________________ Attachments : stm32f4_discovery_msc_sdhc_release_1.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtZW&d=%2Fa%2F0X0000000aRs%2FabJy6M7lXP0vxZjlXODQPOPNQrRf.xKTQu_yEq4Ewao&asPdf=false2012-06-26 07:58 AM
My Notes on Porting the Stm3240g Code over to Stm32F4Discovery :
* CardDetect had to be rewired to PH0 and reconfigured in stm324xg_eval.h : #define SD_DETECT_PIN GPIO_Pin_0 /* PH.0 */ #define SD_DETECT_GPIO_PORT GPIOH /* GPIOH */ * In stm324xg_eval.c comment out code for unused periphs like Buttons etc. * Tested successfully using 128MB and 512MB SD Cards. Also, you can try testing around the Card Detect -by ignoring it in stm324xg_eval_sdio_sd.c : 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) // SD_DETECT_PIN=PH13 if( 0 ) // - TEST { status = SD_NOT_PRESENT; } return status; }2012-06-29 11:20 AM
Maybee a stupid question but how do i convert a uint64_t to string
i wan't to display the cardsize on my glcd2012-06-29 02:02 PM
Maybee a stupid question but how do i convert a uint64_t to string i wan't to display the cardsize on my glcd
Would depend on your tool chain and printf support. You could easily get it into a 32-bit range by dividing into GB, MB or KB units. An off the cuff 64-bit unsigned to ASCII could look like this
char *dec64(uint64_t i)
{
static char string[32]; // enough for 20 digits + NUL
char *s = string + sizeof(string);
*--s = 0;
do
{
*--s = '0' + (char)(i % 10);
i = i / 10;
} while(i);
return(s);
}
I might also mention that you should be putting 47K pull-ups on the D0..D3, CMD and CARDDETECT pins.
2012-06-30 12:04 AM
thanks a lot, know i can display the card size :)
looks like works for me. next thing display a bmp from sd to the display.2012-07-05 08:57 AM
@ clive1...where is the keil 4 project file as mentioned by you....where is the working code download link...please share...need that urgently
2012-07-05 09:35 AM
it is his attachment, in the titel of every post you can see if there is an attachment or not.
just look for the paperclip
2012-07-05 10:05 AM
@ clive1...where is the keil 4 project file as mentioned by you....where is the working code download link...please share...need that urgently
I've only posted the GNU project as it is stand-alone. The Keil one has library/source dependencies. You will need to email to get a copy of it.2012-07-09 03:02 AM
why i am getting the format the card when i want to open that...and during format the formatting ends with the error ''system cannot complete the formatting''
i am using 2gb card...