SD driver for STM3210C eval using FatFs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-01-17 1:23 AM
Hi guys,
I'm working for the first time on a STM3210C eval. I have to store files on the SD card included in the STM card. So I added FatFs to my project. As FatFs is platform independant, I have to find a compatible SD driver which can provide several functions : disk_ioctl(), disk_read(), etc... I've searched on the Internet and tried to add many drivers, without success. Has someone a SD card driver for STM3210C eval which is compatible with FatFs, and a short ''how to do'' would be great :) thanks, Nicolas #stm3210c-eval-fatfs-sd-driver- Labels:
-
FatFS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-01-18 1:25 AM
The attached file may help you. also on the following an example based on STM32F2 and STM32F4.
STM32F2 and STM32F4 demonstration builder platform: http://www.st.com/internet/mcu/product/252jsp ________________ Attachments : diskio.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I0tK&d=%2Fa%2F0X0000000bgu%2FhRMSD1bC2TDMV6ATzYZyDF3utsyZo85baXvpfSyDPSw&asPdf=false- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-01-18 7:43 AM
And here's another example, this was from a project which ran on the STM3210C eval board.
Cheers, Mark ________________ Attachments : disk_io.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtW3&d=%2Fa%2F0X0000000aR8%2Fhi0lzhTc.XQ.fM7U3IVGXWWdSTPy8VpIkDrbhvOULjw&asPdf=falsediskio.h : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtII&d=%2Fa%2F0X0000000aLB%2FtXeVc8krFLmakC39JJZFCEiyj8amUvXhzFFXQSq3XQI&asPdf=falsesdcard.c : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtW8&d=%2Fa%2F0X0000000aR9%2F4cFtJ5ITDcA2m2Nff0A8vzhlXJidtE59t7Abbix6UBo&asPdf=falsesdcard.h : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HtWD&d=%2Fa%2F0X0000000aRA%2FdcR0xa.nrzTRzVz9E.lwZnpR_M1KxGgGJd5CoFZeJzU&asPdf=false- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-01-21 2:44 AM
Thank you for your answers.
@mclean.mark : ''global.h'' in the c files is not recognized by my compiler. I managed to compilate by replacing ''global.h by : #include ''stm32f10x_sdio.h'' #include ''stm32f10x_dma.h'' #include ''stm32f10x_rcc.h'' #define NULL ((void *)0) I modified SDIO_configuration in sdcard.c : static void SDIO_Configuration(void) { GPIO_InitTypeDef GPIO_InitStructureA; GPIO_InitTypeDef GPIO_InitStructureC; RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOC, ENABLE); GPIO_InitStructureC.GPIO_Pin = GPIO_Pin_10 | GPIO_Pin_11 | GPIO_Pin_12; GPIO_InitStructureC.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructureC.GPIO_Mode = GPIO_Mode_AF_PP; GPIO_Init(GPIOC, &GPIO_InitStructureC); /* Configure PD.02 CMD line */ GPIO_InitStructureA.GPIO_Pin = GPIO_Pin_4; GPIO_InitStructureA.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructureA.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_Init(GPIOA, &GPIO_InitStructureA); } But it still doesn't work when I do in the main : FIL fil_obj; FATFS fs[1]; FRESULT FRes; disk_initialize(0); f_mount(0, &fs[0]); f_open(&fil_obj, ''0:whatever.txt'', FA_OPEN_ALWAYS | FA_READ); f_close(&fil_obj); f_mount(0, NULL); Note : I use the firmware 3.3.0, and the processor is a STM3210f107VC Some ideas ?- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-01-21 2:51 AM
your SDIO init is not correct it should be more like this
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_SPI_DETECT_PIN pin: SD Card detect pin */ GPIO_InitStructure.GPIO_Pin = SD_DETECT_PIN;// GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU; // Pull up on board GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 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(SD_SDIO_DMA_CLK, ENABLE);}- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-01-21 3:14 AM
ignore my last post your not using SDIO interface.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2013-01-21 4:48 AM
Some ideas ?
disk_initialize() is called internally by FatFs. FatFs returns errors, examine them and don't continue to plough forward if it fails. Use a debugger and scope if you need to understand what's happening. Debug and test the SD read/write routines outside of FatFs, if they don't work standalone, they aren't going to work when integrated, and debugging is harder.
Up vote any posts that you find helpful, it shows what's working..
