金牌会员
 
- 积分
- 1861
- 金钱
- 1861
- 注册时间
- 2012-5-19
- 在线时间
- 286 小时
|
20金钱
- //sd卡数据复制到U盘
- void SDDataToUpanProcess(void)
- {
- //FATFS fs_; //逻辑磁盘工作区
- FIL U_fdst; //文件
- FRESULT res;//状态变量
- typedef unsigned int UINT;
- UINT br_,bw_;
- res = f_open(&U_fdst,"2:\1.txt",FA_WRITE | FA_CREATE_ALWAYS); //打卡U盘
- if(res !=FR_OK){DEBUG_printf("U_open_ERR:%d\r\n",res); return ;}
- else{DEBUG_printf("U_open_OK\r\n");}
-
- while(1)
- {
- res = f_write(&U_fdst,"1234578\r\n",10,&bw_); 在这里不出来不知道为什么?
- res = res;
- if(res || bw_ < br_){DEBUG_printf("U_write_error disk full:%d-%d\r\n",res,bw_); break ;}
- }
- f_close(&U_fdst);
- DEBUG_printf("f_close\r\n");
- }
复制代码 res = f_write(&U_fdst,"1234578\r\n",10,&bw_); 在这里不出来不知道为什么?
下面的代码创建1.txt文件是正常的
- //sd卡数据复制到U盘
- void SDDataToUpanProcess(void)
- {
- //FATFS fs_; //逻辑磁盘工作区
- FIL U_fdst; //文件
- FRESULT res;//状态变量
- typedef unsigned int UINT;
- UINT br_,bw_;
- res = f_open(&U_fdst,"2:\1.txt",FA_WRITE | FA_CREATE_ALWAYS); //打卡U盘
- if(res !=FR_OK){DEBUG_printf("U_open_ERR:%d\r\n",res); return ;}
- else{DEBUG_printf("U_open_OK\r\n");}
- f_close(&U_fdst);
- DEBUG_printf("f_close\r\n");
- }
复制代码
|
最佳答案
查看完整内容[请看2#楼]
找到问题了,是u盘的兼容问题,用金士顿的就没有问题,用闪迪的就不行,不知道如何优化代码
把u的库升级最新的v2.2问题完美解决了,
|