中级会员
 
- 积分
- 216
- 金钱
- 216
- 注册时间
- 2013-1-12
- 在线时间
- 3 小时
|

楼主 |
发表于 2013-6-13 13:28:28
|
显示全部楼层
回复【6楼】qq942266575:
---------------------------------
我把f_mount位置调整了一下可以执行了,但下面的语句又执行出错了!
creat(void)
{
FATFS fs;
FIL file;
FRESULT res;
u8 string[]="stm32实验";
u8 buffer[512];
UINT br;
UINT bw;
f_mount(0,&fs); //初始化必须mount
res=f_open(&file,"0:/data.txt",FA_CREATE_NEW|FA_WRITE);
res=f_write(&file,string,sizeof(string),&bw);
res=f_close(&file);
res=f_open(&file,"0:/data.txt",FA_OPEN_EXISTING|FA_READ);
res=f_read(&file,buffer,sizeof(buffer),&br);
printf("/r/n%s",buffer);
res=f_close(&file);
}
在执行f_open时又出错了,
进入ff.c,跟踪到下面的一个函数
FRESULT chk_mounted ( /* FR_OK(0): successful, !=0: any error occurred */
const TCHAR **path, /*  ointer to pointer to the path name (drive number) */
FATFS **rfs, /*  ointer to pointer to the found file system object */
BYTE chk_wp /* !=0: Check media write protection for write access */
)
{
BYTE fmt, b, *tbl;
UINT vol;
DSTATUS stat;
DWORD bsect, fasize, tsect, sysect, nclst, szbfat;
WORD nrsv;
const TCHAR *p = *path;
FATFS *fs;
/* Get logical drive number from the path name */
vol = p[0] - '0'; /* Is there a drive number? */
执行到vol这一句又出错了,怎么解决?谢谢! |
|