2012-12-25 09:36 PM
Hi
This question is meant specifically for Clive1. Your earlier post on FAT at https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https%3a%2f%2fmy.st.com%2fpublic%2fSTe2ecommunities%2fmcu%2fLists%2fcortex_mx_stm32%2fST32f4discovery%2bsdcard%2bfatfs%20problem&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=2587This has been very helpful to me and I have modified the code to suit for STM3240G eval board. But the code gets stuck in an infinite loop in the sdio_sd.c file at line 2731.I do not seem to understand what the problem is. I would apprecite your advice regarding this.Thanks in advance. #think! #think!2012-12-26 03:05 AM
''But the code gets stuck in an infinite loop in the sdio_sd.c file at line 2731''
Why don't you post the section of code - so that we can see?''I do not seem to understand what the problem is''Think about what the code is waiting for - How would it normally get out of that loop? When you know what it's waiting for, you can think about why that might not be happening - or might not be getting detected (properly)...2012-12-26 07:38 AM
There should be SD Card support code directly in the STM3240G-EVAL project codes.
I built a ported version for the STM32F4-Discovery, which includes FatFs support.https://docs.google.com/open?id=0B7OY5pub_GfIcU1XTDFDRlptZDg
Hang-ups are most likely due to interrupt handling issues with either SDIO or DMA2012-12-26 07:42 AM
Thanks for the reply
The code is stuck in a while loop waiting for a flag actually.while (!(SDIO->STA & (SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DBCKEND | SDIO_FLAG_STBITERR))) { if (SDIO_GetFlagStatus(SDIO_FLAG_RXDAVL) != RESET) { *(tempscr + index) = SDIO_ReadData(); index++; } }The 'if' condition is not entered.This is my first experience with fat and sd cards, and would really appreciate some help regarding this.2012-12-26 07:47 AM
Well, I have used your code as a guidance and modified it for the stm3240g. The examples have codes for sd card but it just writes hex values directly and I am trying to implement fat.
while (!(SDIO->STA & (SDIO_FLAG_RXOVERR | SDIO_FLAG_DCRCFAIL | SDIO_FLAG_DTIMEOUT | SDIO_FLAG_DBCKEND | SDIO_FLAG_STBITERR))) { if (SDIO_GetFlagStatus(SDIO_FLAG_RXDAVL) != RESET) { *(tempscr + index) = SDIO_ReadData(); index++; } }Actually, this while loop goes on infinitely and if condition is not satisfied.2012-12-27 01:57 AM
''it just writes hex values directly and I am trying to implement fat''
Obviously, if you can't do the basic thing of just writing ''raw'' hex values, then you have no chance with higher-level stuff like FAT!!''if condition is not satisfied''
So, again, think about what that tells you!
What condition would be necessary to satisfy the condition? Why might that not be happening?
2012-12-27 05:04 AM
I am trying to store images in the sd card. So, without fat, it works just fine for a single image. Now for storing multiple images, I started running into problems and I was adviced to implement fat instead. So that is what I meant by just hex and not fat
2012-12-27 10:26 AM
The EVAL board has an SD library, FatFs will need to to interface to it via the abstraction routines in diskio.c
STM32F4xx_DSP_StdPeriph_Lib_V1.0.0\Utilities\STM32_EVAL\STM3240_41_G_EVAL\stm324xg_eval_sdio_sd.c The ST code doesn't handle SD cards quite as it should, the non-HC cards need to be told a block length, and the HC cards can be bigger than 4GB. These are thing I believe I addressed in my working port to the STM32F4-Discovery, and my F2/F4 custom board. I don't have an STM3240G-EVAL, else I might look at this myself.2012-12-28 06:52 AM
I am using a 2Gb SD card. I would really apprecite if you could tell me why is it actually stuck in the loop. Also, it does not enter the if condition. I have a file named 'MESSAGE.TXT' in the SD card. So, it should work right?
Also the data is not available in the receive FIFO. why is that? The sd card is not empty.2012-12-28 08:32 AM
I was using DMA mode, not POLLING.
Suggest you get the original STM3240G-EVAL code running, and dig into the SD Card specification documentation. Not sure how the polling deals with the termination of a block read.