cancel
Showing results for 
Search instead for 
Did you mean: 

sdcard blocksize change

websat13
Associate II
Posted on November 05, 2015 at 15:23

hello

i am working on a project using stm32f103vft6, the purpose is to save audio data from

a mems microphone to a sdcard. the problem is when i want to change teh blocksize in the sdcard configuration from 512 to 2048 i have an error. it accepts only the 512 bytes block.

i am using SAMSUNG 16GB Class10 and ADATA 16GB Class10 UHS1.

thanks
4 REPLIES 4
Posted on November 05, 2015 at 16:42

Why do you need to change it?

You can read/write MULTIPLE blocks, it's more efficient that way, you can easily write 32KB of data in a single operation.

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

hello clive

i have a timing problem, and i have to write data in the sdcard before

before the dma buffer be full.

i have 2 buffers that i use to write data in sdcard, the first one is fill with data

when the dma buffer is in half part and the second is fill when the dma buffer is full.

between the 2 dma interrupts(half and full) i have 74 ms. and between this 2 interrupts

i lost data.

how do i write an entire 32kb block in one time.

thanks

Posted on November 05, 2015 at 19:16

Using the ping/pong HT/TC method is a common way of dealing with audio data. The memory write could occur in the foreground.

Around here we use FatFs and just f_write large blocks, and have the abstraction in diskio.c coded properly to pass large read/write down to the SDIO/SPI layer STM32F10x_StdPeriph_Lib_V3.5.0\Utilities\STM32_EVAL\Common\stm32_eval_sdio_sd.c

/**
* @brief Allows to write blocks starting from a specified address in a card.
* The Data transfer can be managed by DMA mode only.
* @note This operation should be followed by two functions to check if the
* DMA Controller and SD Card status.
* - SD_ReadWaitOperation(): this function insure that the DMA
* controller has finished all data transfer.
* - SD_GetStatus(): to check that the SD Card has finished the
* data transfer and it is ready for data.
* @param WriteAddr: Address from where data are to be read.
* @param writebuff: pointer to the buffer that contain the data to be transferred.
* @param BlockSize: the SD card Data block size. The Block size should be 5
* @param NumberOfBlocks: number of blocks to be written.
* @retval SD_Error: SD Card Error code.
*/
SD_Error SD_WriteMultiBlocks(uint8_t *writebuff, uint32_t WriteAddr, uint16_t BlockSize, uint32_t NumberOfBlocks)
{...

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

hello clive

thanks for th information

i have tested the block size transfer, it works fine but sometimes the transfer is interrupted.

i have found that in the writeblock function at the end there is a test about the sdcard state :

/*!< Add some delay before checking the Card Status */

  for(count = 0; count < 0xFFFF; count++) // 0xFFFF

  {

  }

  /*!< Wait till the card is in programming state */

  errorstatus = IsCardProgramming(&cardstate);

  while ((errorstatus == SD_OK) && ((cardstate == SD_CARD_PROGRAMMING) || (cardstate == SD_CARD_RECEIVING)))

  {

    errorstatus = IsCardProgramming(&cardstate);

  }

in normal mode the cardstate is SD_CARD_TRANSFER.

but when the transfer is interrupted the cardstate is :  SD_CARD_RECEIVING

and it happens at any time.

thanks