• AVR Freaks

FatFs compilation error

Author
d123456789
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2015/04/10 02:24:16
  • Location: 0
  • Status: offline
2015/06/22 06:38:17 (permalink)
0

FatFs compilation error

I am using a PIC18F25k80 microprocessor and an MPLAB X XC8 compiler. I am trying to create a file so I can store data inside an SD card. I am using the functions from "FatFs - Generic FAT File System Module" (can be found at: ). I have created the following function, which is supposed to create a new file and right "Hello World!" inside it.

int createFile()
{
    FIL file; /* File object */
    FRESULT fr; /* FatFs return code */
    UINT br, bw; /* File read/write count */
    BYTE test = "Hello World!";

    /* Register work area to the default drive */
    f_mount(&FatFs, "", 0);

    /* Open a text file */
    fr = f_open( &file, "measurement.txt", FA_CREATE_NEW | FA_WRITE );
    if (fr)
        return (int)fr;

    fr = f_write(&file, test, br, &bw); /* Write it to the destination file */
    if (fr || bw < br)
        return -1; /* error or disk full */

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

    return 0;
}

After compiling I am getting an error saying "error: (1250) could not find space (546 bytes) for variable _file". I don't know why I am getting this error.
 
Thank you.
#1
jtemples
عُضْوٌ جَدِيد
  • Total Posts : 11420
  • Reward points : 0
  • Joined: 2004/02/13 12:31:19
  • Location: Southern California
  • Status: offline
Re: FatFs compilation error 2015/06/22 09:44:34 (permalink)
+2 (2)
"file" uses too much RAM to be placed on the stack.  Make it static or move it to file scope.
#2
d123456789
New Member
  • Total Posts : 27
  • Reward points : 0
  • Joined: 2015/04/10 02:24:16
  • Location: 0
  • Status: offline
Re: FatFs compilation error 2015/06/23 03:16:02 (permalink)
+1 (1)
I made it global and it compiles. Thank you!
#3
Jump to:
© 2019 APG vNext Commercial Version 4.5