cancel
Showing results for 
Search instead for 
Did you mean: 

While integrating SD card with Stm32 in SDIO, FATFS. How can i make the text enter in new line? and also how can i save an integer not characther, How can that be feasible?

Apill
Senior

I am referring to FATFS library

1.I tried to use \n and \t it didnt work. i wanted to make text appear in a new line.

2. in the memory card i wanted to store a vairable integer, How can i do that? As of now i could able to save only character.

In FATFS is there any other way i can save data apart from .txt file?

1 ACCEPTED SOLUTION

Accepted Solutions

How do you normally do file IO with STDIO functions? FATFS is pretty similar.

Use \r\n

int x = 1234;

f_write(&fil, &x, sizeof(x), &byteswritten); // pretty inefficient

>>In FATFS is there any other way i can save data apart from .txt file?

f_write() writes binary data, it doesn't know you're using a text file.

Name files how you want.

Write the content you want.

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

5 REPLIES 5

How do you normally do file IO with STDIO functions? FATFS is pretty similar.

Use \r\n

int x = 1234;

f_write(&fil, &x, sizeof(x), &byteswritten); // pretty inefficient

>>In FATFS is there any other way i can save data apart from .txt file?

f_write() writes binary data, it doesn't know you're using a text file.

Name files how you want.

Write the content you want.

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

@Community member​ , i have exactly used the above mentioned lines. I have got the output as below;

 Ò 

I tried to output to .txt file and .binary file. the same issue. Any suggestions please

File content does not depend on the naming.

Files are a collection of bytes.

Data stored in a native binary form does not appear in human readable ASCII.

Use a file viewer or hex editor to review the content of a file.

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

if i write the following:

char myData [] = " hello ashok\0";

f_write(&myFILE, myData, sizeof(myData), &testByte);

The output of the above is:

hello ashok.

How can it differ from characther to numbers

Certainly indicative of a problem at the SDIO or FATFS levels.

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