cancel
Showing results for 
Search instead for 
Did you mean: 

SDIO and SD fat access example?

natblist
Associate
Posted on February 09, 2012 at 01:06

Hi Chaps,

Going slowly mad trying to get Chan Fat working with the sdio libs on a stm32f4.

I'm using the most recent (1.0.0) library for the F4, and the low level access demo within that library builds and (at least appears to ) work OK. 

I've spent many, many hours attempting to patch in 0.9 version of fatfs from chan (thks chan, you're a hero) - but I can't get it to work.

If possible, I'd really really appreciate a demo project/source (or direction to - though I've scoured the web and can't find anything that works!)

I'll post separately about the current problems I'm having with the my current build, but a working example would sort it.

Many thanks,

nat.

#hse-sdio-stm32 #stm32-fat-chanfat-fatfs-sdio #sdcard-stm32f4-sdio-fatfs #sdcard-stm32f4-sdio-fatfs
84 REPLIES 84
roy23
Associate II
Posted on June 08, 2015 at 17:57

see attached file with comparison of the system_stm32f4xx.c file in my project(left) and in yours(right). I know the board designer took the stm32f407 discovery board as reference. the crystal on target board is 25Mhz like the disco.

its different then your configuration. what do I need to do to make both the sdio and all peripheral's to work at the same time ?

________________

Attachments :

Capture.PNG : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I10P&d=%2Fa%2F0X0000000bgm%2FDz3e0YjHfOaSbmj.tdluk794JOAWDhpxOg5Cn2Xh13Q&asPdf=false
Posted on June 08, 2015 at 18:18

The DISCO boards use an 8 MHz source, the EVAL boards typically used 25 MHz

The comments are not where the clocks are actually defined.

/* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL_M) * PLL_N */
#define PLL_M 25 // For 25 MHz source, to 1 MHz comparison frequency
#define PLL_N 336
/* SYSCLK = PLL_VCO / PLL_P */
#define PLL_P 2 // 168 MHz (336/2)
/* USB OTG FS, SDIO and RNG Clock = PLL_VCO / PLLQ */
#define PLL_Q 7 // 48 MHz (336/7)

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
roy23
Associate II
Posted on June 08, 2015 at 20:29

these are the values in my system_stm32f4xx.c file. The last row in the  table in the comparison. mentions the sdio, usb is disabled. what do I need to do to make it enable ? 

Posted on June 08, 2015 at 20:48

these are the values in my system_stm32f4xx.c file. The last row in the  table in the comparison. mentions the sdio, usb is disabled. what do I need to do to make it enable ? 

Use the diff tool and look at where the PLL defines are used. I'm pretty sure setting the Q tap is sufficient. Look at where it's programming the RCC registers, and review the Reference Manual for additional detail.

If you're concerned about the internal clocks, output them via the MCO pins are review with a scope.

Make sure that HSE_VALUE within the project matches crystal frequency you are using. All the other peripheral clocks come off the APB buses, these should all work irrespective of the SDIO (48 MHz) clock.

I'm not going to try and second guess what's going on based on the software/hardware I don't have.
Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
roy23
Associate II
Posted on June 09, 2015 at 07:25

see below memory if three first registers CR, PLL_CFGR, RCC_CFGR after init.

The when the pll is on the sdio works fine. but the usart6 is gone.

after system_stm32f4xx.c startup, sdio work fine( it seems pll is on 03 0x40023803) usart not working

Address   0 - 3     4 - 7     8 - B     C - F

40023800  83840303  19544007  0A940000  00000000

after calling hse turn on -  pll is off, sdio not working usart6 working

Address   0 - 3     4 - 7     8 - B     C - F               

40023800  83840300  10300024  0000000  00000000

roy23
Associate II
Posted on June 09, 2015 at 08:12

Now I realize when the pll is on source of uart clock is somehow changed. I checked with scope. before pll configuration 115200 baud = 8.68us per bit. After 115200 baud is ~26us bit. is there a way to reconfigure to work ?  

~26us per it is not standard baud rate. what can I do ?

hariprasad
Associate III
Posted on June 09, 2015 at 09:33

Hi Clive,

You've mentioned the sd card performance as below

51200 Bytes, 471825 Cycles

13.021777 MBps Read

I'm little confused about the term ''Cycles'' ,, Does it mean you read 51200 bytes 471825 times ? or is there any other meaning is there?

You'll need Skype Credit

Free via Skype

sabhijithofficial
Associate II
Posted on October 30, 2015 at 06:42

https://docs.google.com/open?id=0B7OY5pub_GfIa2k2MmFzelZFR1U

Hi ,

 I am trying to write SD card at raw level using STM32F4. I  don't know whether it is possible and where to begin. Can you please help me?

Posted on October 30, 2015 at 13:05

I am trying to write SD card at raw level using STM32F4. I  don't know whether it is possible and where to begin.

Bit puzzling then as to why you'd need to do that.

The Raw IO functions exist below the FatFs implementation. You can read/write single sectors, or multiple sectors, from the media, just like any other block storage device.

STM32F4xx_DSP_StdPeriph_Lib_V1.5.1\Project\STM32F4xx_StdPeriph_Examples\SDIO\SDIO_uSDCard

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on October 30, 2015 at 13:14

I'm little confused about the term ''Cycles'' ,, Does it mean you read 51200 bytes 471825 times ? or is there any other meaning is there?

Machine Cycles are my unit of time measurement. For a processor running at 168MHz, Seconds = Cycles / 168,000,000

Depending on how I've configured the software, you're looking at a 32768000 byte file, accessed a 1000 sequential 32768 byte blocks.

You'll need Skype Credit

Free via Skype

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..