xpress_embedo
Advanced Member level 4
- Joined
- Jul 5, 2011
- Messages
- 1,154
- Helped
- 161
- Reputation
- 396
- Reaction score
- 189
- Trophy points
- 1,353
- Location
- India
- Activity points
- 10,591
Hello!! i am using PIC32 and FATfs library to create text file in memory card.
Creating a file is successful and works perfectly.
But i am not able to append anything to the file.
Whenever i tried to do so, text in the file gets corrupted with junk characters.
Here is my code, please help me.
Creating a file is successful and works perfectly.
But i am not able to append anything to the file.
Whenever i tried to do so, text in the file gets corrupted with junk characters.
Here is my code, please help me.
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 int main (void) { FATFS fs; FIL fdst; FRESULT res; UINT numread; DWORD size; unsigned char buffer[] = "This is a text file."; // Enable optimal performance INTEnableSystemMultiVectoredInt(); SYSTEMConfigPerformance(GetSystemClock()); mOSCSetPBDIV(OSC_PB_DIV_1); // Use 1:1 CPU Core:Peripheral clocks //Initialize the disk disk_initialize(0); f_mount(0,&fs); res = f_open(&fdst,"file.txt",FA_WRITE | FA_OPEN_ALWAYS | FA_READ); size = (&fdst)->fsize; res = f_lseek(&fdst,size+1); res = f_write(&fdst,buffer,21,&numread); f_close(&fdst); f_mount(0,NULL); while(1); }