我用的是FATFSR0.12版本,sd卡为手机上的16G卡。运行下面的程序返回值为FR_NO_FILESYSTEM, /* (13) There is no valid FAT volume */。请问这是啥意思?还有这个volume具体怎么翻译?程序和运行结果如下
#include "stm32f10x.h"
#include "diskio.h"
#include "ff.h"
#include "sdcard.h"
#include "bsp_usart1.h"
#define READ_BUFFER_SIZE 25
FATFS fs;
BYTE WriteBuffer[] = "this is a text file,hhhhhhhh";
BYTE ReadBuffer[READ_BUFFER_SIZE] = {0};
UINT bw,br;
int main(void)
{
int i;
FIL fil;
FRESULT fr;
/*config NVIC*/
NVIC_Configuration();
/*config USART1*/
USARTx_Config();
printf("USART config successful\n");
/* Register work area to the default drive /
fr = f_mount(&fs,"0:message.txt",0);
printf("fmount:fr is %d\n",fr);
/ Open a text file */
fr = f_open(&fil, "0:message.txt", FA_CREATE_ALWAYS | FA_WRITE | FA_READ);
printf("fopen:fr is %d\n",fr);
if(fr) return (int)fr;
/*write*/
fr = f_write(&fil,WriteBuffer,sizeof(WriteBuffer),&bw);
printf("fwrite:fr is %d\n",fr);
if(fr) return (int)fr;
/*read*/
fr = f_read(&fil,ReadBuffer,READ_BUFFER_SIZE,&br);
printf("fread:fr is %d\n",fr);
if(fr) return (int)fr;
/*close*/
f_close(&fil);
/* Unregister work area to the default drive */
f_mount(0, "0:message.txt",0);
/**/
printf("successful");
for(i=0;i <= READ_BUFFER_SIZE;i++)
printf("%c",ReadBuffer[i]);
}
运行结果如下:
USART config successful
fmount:fr is 0
this is SDInit process
power on
命令0发送成功,status is 0
此卡遵循2.0协议,status is 0
此卡为sd卡,status is 0
power on success initialize begin
select card succcessful
wide bus succcessful
fopen:fr is 13