Skip to main content
arunease
Associate III
October 21, 2015
Question

Merge SDIO with FATFS

  • October 21, 2015
  • 10 replies
  • 1767 views
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.

    This topic has been closed for replies.

    10 replies

    Tesla DeLorean
    Guru
    October 21, 2015
    Posted on October 21, 2015 at 14:26

    You provide interface/abstraction routines in DISKIO.C

    Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
    arunease
    aruneaseAuthor
    Associate III
    October 22, 2015
    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
    October 22, 2015
    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
    aruneaseAuthor
    Associate III
    October 22, 2015
    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
    October 22, 2015
    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
    aruneaseAuthor
    Associate III
    October 22, 2015
    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.
    Tesla DeLorean
    Guru
    October 22, 2015
    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 VenmoUp vote any posts that you find helpful, it shows what's working..
    arunease
    aruneaseAuthor
    Associate III
    October 23, 2015
    Posted on October 23, 2015 at 11:47

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

    Tesla DeLorean
    Guru
    October 23, 2015
    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 VenmoUp vote any posts that you find helpful, it shows what's working..
    arunease
    aruneaseAuthor
    Associate III
    October 26, 2015
    Posted on October 26, 2015 at 14:02

    seen a wrong address.. 

    i have made it to read and write. 

    Thank you all.