初级会员

- 积分
- 108
- 金钱
- 108
- 注册时间
- 2015-11-30
- 在线时间
- 22 小时
|
10金钱
阿波罗的开发板,使用的是FATFS实验源码,我新建的文件,向新建文件写入数据失败
while(1)
{
i++;
if(i > 0x2000000)
{
i = 0;
j++;
LED0=!LED0;
sprintf(buff, "Now j is %d", j);
res=f_open(&fdst,(const TCHAR*)"2:/a.txt",FA_WRITE|FA_READ|FA_CREATE_ALWAYS);
if(res==0)
{
res=f_write(&fdst,buff,19,(UINT*)&bw);
if(res || bw ==0)
printf("file write error!\r\n");
else
{
printf("Write a.txt:%s\r\n", buff);
buff[0] = 0;
res=f_read(&fdst,buff,19,(UINT*)&bw);
if(res)
printf("file a.txt read error!\r\n");
else
printf("Read a.txt:%s\r\n", buff);
}
}
else
printf("file a.txt open error!\r\n");
}
}
以上是主程序,其他地方的程序我没有改动,串口输出结果是 Read a.txt:(为空)
|
最佳答案
查看完整内容[请看2#楼]
已经解决,原来是没有关闭文件,导致文件文件没有同步到SPI FLASH中去,再次瞎咋综合实验的时候,文件就不存在。
|