L.R.A

SD card data logging

3 posts in this topic

HI EVERYONE,

Long time no see. University has been hard, not time for anything.

But I am back into the MCU world! And I am having some problems so I first would like to know if anyone ever tried this.

I am using a SD card to save data with FATFS. The problem is that the MCU is also doing other stuff...
I've been having writes of a few ms which is normal with FATFS. I am considering of course trying to write 512bytes at a time but also implementing DMA on the SPI. But I am not sure the DMA will help.


It seems FATFS f_write and the port function disk_write, want to right away read or write more stuff into the card, meaning I would anyway have to wait the couple of ms... Am I wrong in this?


(from what I've seen I probably have to directly write into the SD card after pre-allocating a file if I want the DMA to help)

Share this post


Link to post
Share on other sites

I think the smallest sector that can be written is 512 bytes. Even if you want to change one byte in there, ELM Chan's FatFS would backup 512 bytes, manipulate it and write the full sector back.

You could offload the data writing(and reading) to DMA, but you may run into the card write speed acting as a bottleneck. I believe the FatFS library also does some other bookkeeping functions, separate from the write, like updating file sizes.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now