This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430FR5994: Using FatFS to write to an SD card in binary

Part Number: MSP430FR5994

Hi all

I have recently acquired a MSP430FR5994 Launchpad, and am attempting to adapt elements of the Out-of-Box Experience to my needs. I would like to write binary data to an SD card, however when investigating the FatFS library included with the demo, I cannot locate information on how to do so.

It is my understanding that binary write mode can be selected by inputting "wb"as the mode when using fopen, as described by the following link:

http://www.cplusplus.com/reference/cstdio/fopen/

However, the FatFS library uses f_open, and I have been unable to find how to select binary mode. The below link documents the function, which is similar to fopen in that "r", "r+", "w'" etc. are used, but does not mention binary.

http://elm-chan.org/fsw/ff/doc/open.html

Is there a way to select binary mode using f_open? Alternatively, I have attempted to replace it with fopen (to write to a .txt file as the demo does, at this stage), with little success. Any guidance on how to do so would be appreciated.

Thanks

  • FatFS doesn't really have text/binary mode:
    1) f_read/f_write work with bytes -- if you only use these, you get the equivalent of binary mode.
    2) f_getc/f_gets/et al do some things resembling stdio -- if you only use these, you get the equivalent of text mode. [Disclaimer: I haven't actually used these.]
    I don't know for sure what happens if you mix the two.

    It may be that someone has written a stdio layer (e.g. fopen) on top of FatFS, but I haven't run across it.
  • Hi Bruce

    Thank you for the reply, I'll have a go at implementing the library with f_read and f_write alone

**Attention** This is a public forum