当对官方例程调试时,SD卡调试过程中,对SD卡内的txt文件读是ok的,但加入写SD卡函数f_write时,不能写入数据,并且导致再次读数据也发生错误,请问fatfs系统的写函数是否可用????请大家帮忙看看问题出在哪!!!
以下是写函数代码:
Cmd_send_data(int argc, char *argv[])
{
FRESULT res=FR_OK;
WORD br;
FIL fsrc;
char textFileBuffer[] = "123456789";//{0x12,0x13,0x14,0x15,0x16};
char m[]="0:/fat.txt";
strcpy(g_cTmpBuf, m)
res = f_open( &fsrc , g_cTmpBuf , FA_CREATE_ALWAYS | FA_WRITE);//FA_CREATE_NEW | FA_WRITE);
if ( res == FR_OK )
{
/* Write buffer to file */
res = f_write(&fsrc, textFileBuffer, sizeof(textFileBuffer), &br);
if( res == FR_OK )
{
UARTprintf("hello word!");
}
/*close file */
f_close(&fsrc);
return(0);
}
Seven Han:您参考帖子:e2e.ti.com/…/2414756
当对官方例程调试时,SD卡调试过程中,对SD卡内的txt文件读是ok的,但加入写SD卡函数f_write时,不能写入数据,并且导致再次读数据也发生错误,请问fatfs系统的写函数是否可用????请大家帮忙看看问题出在哪!!!
以下是写函数代码:
Cmd_send_data(int argc, char *argv[])
{
FRESULT res=FR_OK;
WORD br;
FIL fsrc;
char textFileBuffer[] = "123456789";//{0x12,0x13,0x14,0x15,0x16};
char m[]="0:/fat.txt";
strcpy(g_cTmpBuf, m)
res = f_open( &fsrc , g_cTmpBuf , FA_CREATE_ALWAYS | FA_WRITE);//FA_CREATE_NEW | FA_WRITE);
if ( res == FR_OK )
{
/* Write buffer to file */
res = f_write(&fsrc, textFileBuffer, sizeof(textFileBuffer), &br);
if( res == FR_OK )
{
UARTprintf("hello word!");
}
/*close file */
f_close(&fsrc);
return(0);
}
mangui zhang:是不是因为SD卡版本问题
当对官方例程调试时,SD卡调试过程中,对SD卡内的txt文件读是ok的,但加入写SD卡函数f_write时,不能写入数据,并且导致再次读数据也发生错误,请问fatfs系统的写函数是否可用????请大家帮忙看看问题出在哪!!!
以下是写函数代码:
Cmd_send_data(int argc, char *argv[])
{
FRESULT res=FR_OK;
WORD br;
FIL fsrc;
char textFileBuffer[] = "123456789";//{0x12,0x13,0x14,0x15,0x16};
char m[]="0:/fat.txt";
strcpy(g_cTmpBuf, m)
res = f_open( &fsrc , g_cTmpBuf , FA_CREATE_ALWAYS | FA_WRITE);//FA_CREATE_NEW | FA_WRITE);
if ( res == FR_OK )
{
/* Write buffer to file */
res = f_write(&fsrc, textFileBuffer, sizeof(textFileBuffer), &br);
if( res == FR_OK )
{
UARTprintf("hello word!");
}
/*close file */
f_close(&fsrc);
return(0);
}
wenchao li1:
回复 mangui zhang:
多谢回复!可能跟卡版本有关系1