cancel
Showing results for 
Search instead for 
Did you mean: 

can i use SPI on STM32f4 to load data into memory card?

Apill
Senior
  • How can i calculate the speed of microcontroller at what speed it can load data using SDIO 1 bit and also SPI? Can I use SPI to load data into memory card. If yes, do i have to use FATFS library to load ? I have an experience working with SDIO, it uses FATFS.
  • Does the speed depend on coding like using f_write and f_printf or does the speed depend on clock speed( HSI) we provide ?
  • where can i get this information?
  • I am looking for the fastest serial communication possible to load the data into memory card at a rate of 20,000 samples/second.
  •  
1 ACCEPTED SOLUTION

Accepted Solutions

>>How can i calculate the speed of microcontroller at what speed it can load data..

The machine is synchronous, all the clocks have defined ratios to each other.

You can time transfers, like using a stop-watch in real life, to see how long it takes to write blocks of X length. Measure operations over multiple micro or milli-seconds. Use a free running TIM to provide a counter, giving you elapsed time.

FATFS is only needed if you want a file system. You can use memories without that, but it will make interchange difficult. ie If you want to be able to stick a card into a Windows PC it better have a recognized file system, otherwise you have to write apps and drivers, which I don't suspect you know how to do.

Expect SPI / 1-bit mode to be at least 4x slower than SDIO / 4-bit, and likely significantly worse.

There is an AdaFruit SD library in the BSP supporting SPI mode.

>>Does the speed depend on coding like using f_write and f_printf or does the speed depend on clock speed( HSI) we provide ?

It is going to depend on multiple variables, clocking the interface is one, the other is the size and alignment of the data being written. Writing small blobs of data requires a lot of interactions, and will be SLOW, writing ONE sector to the media will also have significant command/response overhead, which can be decimated by writing larger groups of sectors.

>>where can i get this information?

One can infer ceilings using simple math, and try simple experiments.

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

View solution in original post

2 REPLIES 2

>>How can i calculate the speed of microcontroller at what speed it can load data..

The machine is synchronous, all the clocks have defined ratios to each other.

You can time transfers, like using a stop-watch in real life, to see how long it takes to write blocks of X length. Measure operations over multiple micro or milli-seconds. Use a free running TIM to provide a counter, giving you elapsed time.

FATFS is only needed if you want a file system. You can use memories without that, but it will make interchange difficult. ie If you want to be able to stick a card into a Windows PC it better have a recognized file system, otherwise you have to write apps and drivers, which I don't suspect you know how to do.

Expect SPI / 1-bit mode to be at least 4x slower than SDIO / 4-bit, and likely significantly worse.

There is an AdaFruit SD library in the BSP supporting SPI mode.

>>Does the speed depend on coding like using f_write and f_printf or does the speed depend on clock speed( HSI) we provide ?

It is going to depend on multiple variables, clocking the interface is one, the other is the size and alignment of the data being written. Writing small blobs of data requires a lot of interactions, and will be SLOW, writing ONE sector to the media will also have significant command/response overhead, which can be decimated by writing larger groups of sectors.

>>where can i get this information?

One can infer ceilings using simple math, and try simple experiments.

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

Thanks for the detailed answer.