issue in opening two file in fatfs stmcube
Hello,
I have been trying to open two files simultaneously in sdcard (one in READ mode and another one in Write mode) using the STMCUBE IDE fatfs library. Since two files requires two file handles so I have defined below mentioned parameters in the fatfs.h file.
In the ffconf.h file I have defined the FF_VOLUME to 2 since I have two drive one is sdcard and other one is USB.
#define MAX_FILES 2 // Define the maximum number of file handles you need
FIL fileHandle[MAX_FILES];
FILINFO finfo;
FRESULT fres, fres1; // result
UINT ptrr, ptrw; // File read/write count
UINT ubr, ubw; // File read/write count for USB
When I open the fileHandle[0] it open successfully and fres is set as FR_OK. when fileHandle[1] is opened it reset the parameters of the fileHandle[0] (specifically obj.id and obj.fs.id is mismatched) and return FR_OK as response. When I try to read from the file1 using fileHandle[0] , it sends the FR_INVALID_OBJECT Errror which is due to filehandle[0] parameter corruption. The debugging window screenshot is attached.

Why the fileHandle[0] gets corrupted when anotherfile is opened. Please suggest the solution of this problem. I am stuck here.
The code is attached for reference purpose.
