How to create a File correctly

239 views Asked by At

i started working with fatfs a few days ago for reading and writing to a microsd card from my atmega328p. Unfortunately no txt file is created with my code, but i don't get any error out. Does anyone know what the problem could be?

#include "ff14a/source/ff.h"
#include "ff14a/source/diskio.h"
#include <stdio.h>


FATFS FatFs;   /* Work area (filesystem object) for logical drive */

int main (void)
{ 


FIL fil;        /* File object */
char line[100]; /* Line buffer */
FRESULT fr;     /* FatFs return code */


/* Give a work area to the default drive */
f_mount(&FatFs, "0:", 1);

/* Open a text file */
fr = f_open(&fil, "0:FatFs test.txt", FA_WRITE | FA_CREATE_ALWAYS);
if (fr) return (int)fr;



/* Close the file */
f_close(&fil);

return 0;
}

I used this code to create a test.txt File, but as I said, nothing gets created

0

There are 0 answers