0
\$\begingroup\$

I have a STM8S003F3 and a Arduino Micro SD Card Module. I want to create a file inside the Micro SD card. How can I do it? Can you help me?

Thank you in advance.

\$\endgroup\$
0
2
\$\begingroup\$

You will need:

  • to connect these two.
  • point an SD card driver (that you write or get somewhere) at the interface (typically SPI) that connects your microcontroller to your SD card
  • write or get a file system driver for the file system you want to use (e.g. exFAT, littlefs?) that can work with said SD card driver.
  • open the file
  • write data to it
  • close the file
  • sync the file system ("unmount the sd card")

Note that accessing file systems inherently will need a bit of RAM. Chances are that you're making your life pretty miserable by sticking to a microcontroller with only 1 kB of RAM in total. Considering the low cost of 32 bit development platforms these days (see, for example, "stm32 blue pill"), I don't think sticking to STM8 is a wise choice here.

\$\endgroup\$
6
  • \$\begingroup\$ I wish I could upvote again, especially for the last sentence. \$\endgroup\$ – Rohat Kılıç Feb 5 at 15:01
  • \$\begingroup\$ Unfortunately, I have to use STM8S003F3. So, is there any code I can take as an example? \$\endgroup\$ – Ademola Lookman Feb 5 at 16:13
  • \$\begingroup\$ I don't have any. If ST has none it offers with their code examples: probably something exsits, but it'll be hard to find publicly. whoever wrote that would've done that for a system with a lot of cheap devices sold (nobody else would use a STM8 for such a task). A filesystem + SD card driver in 1 kB of RAM is simply pretty annoying to write, and if you're not profiting heavily from it, the engineering hours will be hard to justify. \$\endgroup\$ – Marcus Müller Feb 5 at 17:50
  • \$\begingroup\$ Can you explain the connection between RAM and a filesystem + SD card driver? Why use microprocessor with high RAM? \$\endgroup\$ – Ademola Lookman Feb 7 at 11:21
  • \$\begingroup\$ A filesystem is a large data structure with a lot of strings and tree structures. To work with large datastructures, you need RAM, or you need to be very clever on reading things from your storage medium every time you need them, and that's very slow and complicated and error-prone. I'm not saying you need a microcontroller with "high RAM", just not one with "exceptionally very little RAM" like yours. \$\endgroup\$ – Marcus Müller Feb 7 at 14:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.