for ( i=0; i<512; i++ ) //填充缓冲
{
Tx_Buffer =0xab;
}
// f_mount(fs[0],&quot;0:&quot;,1);
res = f_open(&fnew,&quot;0:/newfile.txt2&quot; , FA_CREATE_ALWAYS| FA_WRITE);
if(res==FR_OK)
{
//res = f_lseek(file, f_size(file));
res = f_write(&fnew, Tx_Buffer,512, &bw);
delay_ms(500);
}
f_close(&fnew);
res = f_open(&fnew,&quot;0:/newfile.txt2&quot; ,FA_OPEN_EXISTING|FA_READ);
res=f_read(&fnew,Rx_Buffer,512,&br);
if(res)
{
printf(&quot;Read Error:%d\r\n&quot;,res);
}else
{
for(t=0;t<br;t++)
{
printf(&quot;OX%04X &quot;,Rx_Buffer[t]);
// printf(&quot;%02x &quot;,Rx_Buffer[t]);
}
}
f_close(&fnew);
f_mount(NULL,&quot;0:&quot;,1);
为什么最后打印出来前255个字节是正确的,后边全为0了,我明明写进去的是516个字节的,为什么写不进去,或者读的不对呢?找不到原因了 |