Have a weird problem now with my Primer2. I've upgraded the OS to V3.8 and Ride to the latest 9/15 release. I have three programs that need to write binary files. It checks to see if the file exists and if so seeks to the end and appends data. If the file is not found, a new one is created. Each are named different. When I run each program, it creates and retains the first file but when I run the 3rd program the second one created is replaced with the 3rd file. If I run the 2nd program, the 3rd program is replaced with the file created with the 2nd program. For example:
Program 1 creates file name ABCD.BIN.
Program 2 creates file name EFGH.BIN.
Program 3 creates file name IJKL.BIN but EFGH.BIN gets deleted.
Anyone experiencing this problem? Any ideas what I'm doing wrong? Each program creates the files using the same code except for the name. SD is initialized the same way also.
Here's the code:
cr = FS_OK;
u32 successcount;
u8 NumFile = 1;
char str[20];
NVIC_InitTypeDef NVIC_InitStructure;
NVIC_InitStructure.NVIC_IRQChannel = SDIO_IRQChannel;
NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
NVIC_Init(&NVIC_InitStructure);
// mount MMCSD
StartMBR=FS_Mount(MMCSD_SDIO);
if (StartMBR == 0xFFFFFFFF)
{
DRAW_Puts("\n No SDCARD");
}
// Open volume on first partition (0)
if (FS_GetVolumeInfo(0, StartMBR, &volume_info))
{
DRAW_Puts("\nErr: GetVolInfo");
}
// Open root directory
if (FS_OpenDirectory(&volume_info, "", &directory_info))
{
DRAW_Puts("\nErr: Open Root");
}
// Open new file
memset((void *) &file_info, 0, sizeof(file_info));
cr = FS_OpenFile(&volume_info, "ABCD.BIN", FS_WRITE, &file_info);
if(file_info.filelen != 0)
{
FS_Seek(&file_info, file_info.filelen + 1 );
}
Any help would be greatly appreciated! Thanks!