cancel
Showing results for 
Search instead for 
Did you mean: 

How can I improve the speed of sdio mode 1 bit and 4 bit ?

Apill
Senior

I need to store atleast 20,000 samples per second to perform FFT. so I have used memory card to store all the values in sd card. currently, I could only able to store 7000 samples at a particular interval of time but not more than that. I tried with one bit sdio mode and 4 bit but of no avail.

Any hints or tips to improve the speed of sdio mode? I also tried to increase the overall frequency of the clock then too it didnt affect the performance of sdio.

in the code for my trail purpose i simply created an array. In future I will store values from ADC inputs in array. when i change the value in array to 8000 and value in for loop to 7999 nothing happens! I could only able to create a .txt file in sd card but i cannot store values.

simple code:

uint16_t array[7000],j=1;

 /* USER CODE BEGIN 2 */

if(f_mount(&myFatFS, SDPath,1) == FR_OK)

{

HAL_GPIO_WritePin(GPIOD, GPIO_PIN_12, GPIO_PIN_SET);

char myFILEName[]="TEST1.txt";

if(f_open(&myFILE, myFILEName, FA_WRITE| FA_CREATE_ALWAYS) == FR_OK)

{

HAL_GPIO_WritePin(GPIOD, GPIO_PIN_13, GPIO_PIN_SET);

for(int i=0; i<=6999; i++)

 {

array[i]=j;

j++;

 }

if(f_write(&myFILE, array, sizeof(array), &myBytes)==FR_OK)

  {

HAL_GPIO_WritePin(GPIOD, GPIO_PIN_15, GPIO_PIN_SET);

    }

f_close(&myFILE);

}

}

1 ACCEPTED SOLUTION

Accepted Solutions

Thanks for the inputs yes, there is a bug i found it! I declared local variable array for some reason it might be storing less amount of bytes when i declared globally it increased the total number of numbers to maximum space of microcontroller flash memory.

View solution in original post

5 REPLIES 5

>> I could only able to create a .txt file in sd card but i cannot store values.

Variables store in binary are not going to display nicely in ASCII via TYPE or CAT type commands, or loading into a text editor.

Look at the data in a File Viewer or Hex Editor

Opening/Closing a file repeatedly will be slow.

The file system and card want stuff in powers of two, ie writes of 8192 bytes or 32768 bytes for instance.

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

File will contain bytes 01 00 02 00 03 00 04 00 ...

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

Are there better alternatives to store numerical data other than .txt format ? If yes can you let me know please .I should be able to view the data in computer after storing.

Yes I am using hex editor to view the data.

I tried with 8192 size of array but for some reason it is not loading in data. I also tried with 32768 as well. one interesting thing is, when i kept the size of array 4096, the system didnt upload data to memory card but when i kept 5000 it worked. for array sizes: 4000,5000,6000,7000, the system worked but for more than 7000 size of array it didnt work !!!!!!

>>Are there better alternatives to store numerical data other than .txt format ?

You've given the file an arbitrary extension, you are writing binary data as 16-bit words to the file. The file in this context is a collection of bytes. It is not text or ASCII formatted.

>>I should be able to view the data in computer after storing.

View them as a human, or have an application read the structures and process as standard 16-bit representations?

If you want to import into Excel you might need a more verbose/human centric format like comma delimited ASCII fields (See .CSV)

Binary data is covered by Computers 101 Data Representation means/methods.

A functional file system shouldn't care if there are 7000 or 8192, suggests there are bugs in stack somewhere.

>>... size of array it didnt work !!!!!!

I don't know how to debug that, what did it actually write vs what was expected?

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

Thanks for the inputs yes, there is a bug i found it! I declared local variable array for some reason it might be storing less amount of bytes when i declared globally it increased the total number of numbers to maximum space of microcontroller flash memory.