I had a tm4c129xnczad microcontroller with SDcard connected to it via SPI3
and the SDcard with 1 Gb size had 2 volumes with about 500 Mb each
I want to write data to files to each volume I can access the first one but the second volume is not accessible through the code I had so the steps I did was
- first I started Mounting the 2 volumes such that
EIO_vmturnSDCardPowerON();
UTIL_vNonOSDelayMiliSeconds(200);/* this delay is guarantee the proper rest for the SD card */
/* Mount and register the FSHELL Card */
SDSPI_Params_init(&objstrsdspiParameters);
objsdspiHandle = SDSPI_open(Board_SDSPI0, DRIVE_NUM, &objstrsdspiParameters);
if(objsdspiHandle == STD_NULL)
{
FSHELL_vmLogError0(&objstrFSHELLModuleInfoType, "Can't mount SD card");
}
else
{
FSHELL_vmLogActivity1(&objstrFSHELLModuleInfoType, "SD card is mounted Drive:%u", DRIVE_NUM);
bSdMountState = STD_TRUE;
}
objsdspiHandle = SDSPI_open(1, 1, &objstrsdspiParameters);
if(objsdspiHandle == STD_NULL)
{
FSHELL_vmLogError0(&objstrFSHELLModuleInfoType, "Can't mount SD card");
}
else
{
FSHELL_vmLogActivity1(&objstrFSHELLModuleInfoType, "SD card is mounted Drive:%u", 1);
bSdMountState = STD_TRUE;
}
- then I used the standard file APIs from the studio.h (fopen, fclose, fwrite ) functions such that
#include <stdio.h>
function (){
...
INT8S *ps8ProgFilePath = "fat:0:/ProgBlocks/Blocks.txt";
INT8S *ps8ProgFilePath_1 = "fat:1:/ProgBlocks/Blocks.txt";
FRESULT objFRESULT = FR_DISK_ERR;
FILE *pSourceFile;
...
objFRESULT = f_mkdir("/ProgBlocks");
if((objFRESULT == FR_OK)||(objFRESULT == FR_EXIST)) /* if folder is created or alredy existed */
{
pSourceFile = fopen((const INT8S*)ps8ProgFilePath, "a");
if(pSourceFile == STD_NULL)
{
SCFGM_vmLogError1(&objstrSCFGMModuleInfoType, "\"%s\" could not be created", (INT32U)ps8ProgFilePath);
}
else
{
u32NumBytesWritten = fwrite((INT8S*)ps8Data,1,(MAX_BLOCK_ID_STRING+(u32BlockLen*3)),pSourceFile);
if (u32NumBytesWritten != (MAX_BLOCK_ID_STRING+(u32BlockLen*3)))
{
SCFGM_vmLogError1(&objstrSCFGMModuleInfoType, "\"%s\"Err wrt Blk", (INT32U)ps8ProgFilePath);
}
}
if(fclose(pSourceFile) != 0)
{
SCFGM_vmLogError1(&objstrSCFGMModuleInfoType, "\"%s\" could not be Close", (INT32U)ps8ProgFilePath);
}
}
....
}
so I can access the first volume "fat:0:" but can't write or even access the second volume "fat:1:" in the same way
so the question is can I even access 2 volumes within the same SD card and how?