本帖最后由 cl17726 于 2017-4-10 14:26 编辑
板子是STM32F769-DISCO
昨天东西还是好好的,结果今天提示写保护,是TF卡,官方板,硬件代码都没改动,怎么会这样呢.换TF卡也不能解决,TF卡在电脑上可以正常读写/。提示写保护,实际上并没有,删掉写保护代码也写不了东西的(当然这个方法应该不对)
初始化用官方工程,降低速率也没用,TF卡品牌不同也测试过。
突然好了几分钟,测试的卡是
闪迪C10
金士顿C4 C10
PNY C4
雷克沙 UHS3
[mw_shl_code=cpp,true]FIL fil;
void testFS(void)
{
FATFS fs;
FRESULT res;
char str[24];
char *buf = "1234567890abcdefghijklmn";
UINT bw;
UINT br;
res = f_mount(&fs, "0:", 1);
LCD_UsrLog("mount %d
", res);
LCD_LOG_UpdateDisplay();
f_getlabel("0:", str, 0);
LCD_UsrLog("label %s
", str);
res = f_open(&fil, "0:gi1me.txt", FA_READ | FA_WRITE | FA_CREATE_ALWAYS);
LCD_UsrLog("open %d
", res);
LCD_LOG_UpdateDisplay();
// res = f_mkdir("0:T1");
// LCD_UsrLog("mkdir %d
",res);
//LCD_LOG_UpdateDisplay();
res = f_write(&fil, buf, 20, &bw);
LCD_UsrLog("f_write %d
", res);
LCD_LOG_UpdateDisplay();
res = f_lseek(&fil, 0);
LCD_UsrLog("f_lseek %d
", res);
LCD_LOG_UpdateDisplay();
res = f_read(&fil, buf, 20, &br);
LCD_UsrLog("f_read %d - %s
", res, str);
LCD_LOG_UpdateDisplay();
res = f_sync(&fil);
LCD_UsrLog("f_sync %d
", res);
LCD_LOG_UpdateDisplay();
res = f_close(&fil);
LCD_UsrLog("f_close %d
", res);
LCD_LOG_UpdateDisplay();
}
[/mw_shl_code]
一周热门 更多>