cancel
Showing results for 
Search instead for 
Did you mean: 

Merge SDIO with FATFS

arunease
Associate II
Posted on October 21, 2015 at 13:33

Hi,

I have created a sdio and i would like to know how to merge the FATFS file system with the SDIO. I have seen some examples but  i am not understanding how the they give a link between file system module and SDIO.

10 REPLIES 10
Posted on October 21, 2015 at 14:26

You provide interface/abstraction routines in DISKIO.C

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arunease
Associate II
Posted on October 22, 2015 at 12:50

ok, now i can see how they integrate it the whole.

i would like to know the following two lines,

SD_Error SD_ReadMultiBlocks(uint8_t *readbuff, uint64_t ReadAddr, uint16_t BlockSize, uint32_t NumberOfBlocks).

SDIO_DataInitStructure.SDIO_DataBlockSize = (uint32_t) 9 << 4

why its uint64_t ReadAddr, is that a 64 bit address ?

whats (uint32_t) 9 << 4 means ?

qwer.asdf
Senior
Posted on October 22, 2015 at 13:36

> why its uint64_t ReadAddr, is that a 64 bit address ?

Yes, otherwise we wouldn't be able to address more than 4GB of space.

 

> whats (uint32_t) 9 << 4 means ?

Go read about

https://en.wikipedia.org/wiki/Bitwise_operation

. In this case it's bitwise logical left shift.

9 << 4 = 9 * (2^4) = 144 = 0x90

I don't know why they did it this way instead of using the SDIO_DataBlockSize_512b definition.

arunease
Associate II
Posted on October 22, 2015 at 14:26

thanks for the answer, qwer.asdf. 

i have done the bitwise operation already and i know it its 144. but i wonder why its 144 insted of 512?.

They say that, SDIO_DataLength = NumberOfBlocks * BlockSize;

so the data block size has to be 512 not 9 << 4.

does nayone know why its like that ?

 

qwer.asdf
Senior
Posted on October 22, 2015 at 14:53

See the description of SDIO_DCTRL register in the reference manual.

...

 

Bits 7:4 DBLOCKSIZE: Data block size

 

...

 

1001: (9 decimal) lock length = 29 = 512 bytes

 

...

 

 

That's why they used 9, and shifted it left by 4 bits to fit it in the bits 7:4 of the register.

arunease
Associate II
Posted on October 22, 2015 at 15:11

yes, u r correct. 

i would like also to know what are the parameters do i need to consider when i need to calculate the writing speed and reading speed?

give me some example of calculating if u can.
Posted on October 22, 2015 at 15:17

You take a free running counter, clocking at a known frequency, and measure the elapsed time in ticks of that counter over the operation you are measuring.

I'd recommend a 32-bit counter, clocking as rapidly as possible. I've posted examples using DWT_CYCCNT

Measure the time with larger blocks (multiple sector read/write), measuring a single sector will just result in seeing all the command processing overhead.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
arunease
Associate II
Posted on October 23, 2015 at 11:47

ok clive.. is it possible to post the link of your example?

Posted on October 23, 2015 at 15:15

I use Google to find my own posts.

[DEAD LINK /public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Duration%20of%20FLOAT%20operations&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B&currentviews=4973]https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=%2Fpublic%2FSTe2ecommunities%2Fmcu%2FLists%2Fcortex_mx_stm32%2FDuration%20of%20FLOAT%20operations&FolderCTID=0x01200200770978C69A1141439FE559EB459D7580009C4E14902C3CDE46A77F0FFD06506F5B¤tviews=4973

Second post, how to use DWT_CYCCNT to stop-watch execution in processor cycles.

You could also use TIM2 (assuming F4) which is a 32-bit timer, just configure the time base with a maximal period, and if it's more convenient set the prescaler so TIM2->CNT ticks with milliseconds, ie Prescaler = 84 -1; // Assuming it's clocking at 84 MHz (APB1 @ 42 MHz)

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