Jump to content

SD card data logging

Recommended Posts


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)

Link to post
Share on other sites
  • 1 month later...
  • 3 weeks later...

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.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...