完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
不太清楚!我帮你把帖子顶起来
|
|
|
|
太谢谢了AAAAAAAAAAAAAAAAAAAAAA
|
|
|
|
只是文件页大小的问题,改下宏就好了
|
|
|
|
大师,我移植了FATFS到flash,发现格式化未成功(未移植操作系统时多扇区(512B)读写没问题,已经测试过),如何配置格式化函数呀:
#define _MAX_SS 512 /* 512, 1024, 2048 or 4096 */ /* Maximum sector size to be handled. / Always set 512 for memory card and hard disk but a larger value may be / required for floppy disk (512/1024) and optical disk (512/2048). / When _MAX_SS is larger than 512, GET_SECTOR_SIZE command must be implememted / to the disk_ioctl function. */ /*-----------------------------------------------------------------------*/ /* Miscellaneous Functions */ DRESULT disk_ioctl( BYTE drv, /* Physical drive nmuber (0..) */ BYTE ctrl, /* Control code */ void *buff /* Buffer to send/receive control data */ ) { DRESULT res = RES_OK; //DWORD result; if (drv) { return RES_ERROR; } switch (ctrl) { case CTRL_SYNC: break; case GET_SECTOR_COUNT: *(DWORD*)buff = (DWORD) 4096; break; //2M byte case GET_SECTOR_SIZE: //*(DWORD*)buff = (DWORD) 2048; //>512时从这里获得扇区大小 break; //单扇区字节数 case GET_BLOCK_SIZE: *(DWORD*)buff = (DWORD) 4096; break; //族大小 case CTRL_POWER : break; case CTRL_LOCK : break; case CTRL_EJECT : break; default: res = RES_ERROR; break; } return res; } int main(void) { UARTInit (); /* UARTInit */ PINSEL0 = PINSEL0 & (~0x0F); /* UART0,设置I/O连接到UART*/ PINSEL0 = PINSEL0 | 0x05; /* P0.0 = TXD0,P0.1 = RXD0*/ UART0SendStr("x0c "); UART0SendStr("x0c "); //超级终端清屏 UART0SendStr(" 33[1;40;32m"); //设置超级终端背景为黑色,字符为绿色 UART0SendStr("rn*******************************************************************************"); UART0SendStr("rn*********************** Copyright 2012-10-10, liujiehan ***********************"); UART0SendStr("rn************************** http://www.upcomputer.com **************************"); UART0SendStr("rn***************************** All Rights Reserved *****************************"); UART0SendStr("rn*******************************************************************************"); UART0SendStr("rn"); /*初始化文件系统,检查芯片是否插入以及是否型号正确*/ res = disk_initialize(NORFLASH); if(res == RES_OK) { UART0SendStr("initialize filesystem successed!nrnr"); } else { UART0SendStr("initialize filesystem failed!nrnr"); } /*挂载文件系统*/ res = f_mount(NORFLASH,&fs); if(res == RES_OK) { UART0SendStr("mount filesystem successed!nrnr"); } else { UART0SendStr("mount filesystem failed!nrnr"); } /*格式化磁盘*/ UART0SendStr("正在格式化磁盘,请稍候...nrnr"); //res = f_mkfs(NORFLASH,1,4096);//4096:每簇占用字节数 res = f_mkfs(NORFLASH,0,4096);//4096:每簇占用字节数 if(res == RES_OK) { UART0SendStr("format filesystem successed!nr"); } else { UART0SendStr("format filesystem failed!nr"); } res = f_mount(NORFLASH,NULL); ///////////////////////////////////////////////////////////////////////////////////////////////// res = f_mount(NORFLASH,&fs); /*写文件测试*/ UART0SendStr("write file test......nr"); res = f_open(&FileObject, "test.txt", FA_CREATE_ALWAYS | FA_WRITE); 。。。 } |
|
|
|
大师,我移植了FATFS到flash,发现格式化未成功(未移植操作系统时多扇区(512B)读写没问题,已经测试过),如何配置格式化函数呀:
#define _MAX_SS 512 /* 512, 1024, 2048 or 4096 */ /* Maximum sector size to be handled. / Always set 512 for memory card and hard disk but a larger value may be / required for floppy disk (512/1024) and optical disk (512/2048). / When _MAX_SS is larger than 512, GET_SECTOR_SIZE command must be implememted / to the disk_ioctl function. */ /*-----------------------------------------------------------------------*/ /* Miscellaneous Functions */ DRESULT disk_ioctl( BYTE drv, /* Physical drive nmuber (0..) */ BYTE ctrl, /* Control code */ void *buff /* Buffer to send/receive control data */ ) { DRESULT res = RES_OK; //DWORD result; if (drv) { return RES_ERROR; } switch (ctrl) { case CTRL_SYNC: break; case GET_SECTOR_COUNT: *(DWORD*)buff = (DWORD) 4096; break; //2M byte case GET_SECTOR_SIZE: //*(DWORD*)buff = (DWORD) 2048; //>512时从这里获得扇区大小 break; //单扇区字节数 case GET_BLOCK_SIZE: *(DWORD*)buff = (DWORD) 4096; break; //族大小 case CTRL_POWER : break; case CTRL_LOCK : break; case CTRL_EJECT : break; default: res = RES_ERROR; break; } return res; } int main(void) { UARTInit (); /* UARTInit */ PINSEL0 = PINSEL0 & (~0x0F); /* UART0,设置I/O连接到UART*/ PINSEL0 = PINSEL0 | 0x05; /* P0.0 = TXD0,P0.1 = RXD0*/ UART0SendStr("x0c "); UART0SendStr("x0c "); //超级终端清屏 UART0SendStr(" 33[1;40;32m"); //设置超级终端背景为黑色,字符为绿色 UART0SendStr("rn*******************************************************************************"); UART0SendStr("rn*********************** Copyright 2012-10-10, liujiehan ***********************"); UART0SendStr("rn************************** http://www.upcomputer.com **************************"); UART0SendStr("rn***************************** All Rights Reserved *****************************"); UART0SendStr("rn*******************************************************************************"); UART0SendStr("rn"); /*初始化文件系统,检查芯片是否插入以及是否型号正确*/ res = disk_initialize(NORFLASH); if(res == RES_OK) { UART0SendStr("initialize filesystem successed!nrnr"); } else { UART0SendStr("initialize filesystem failed!nrnr"); } /*挂载文件系统*/ res = f_mount(NORFLASH,&fs); if(res == RES_OK) { UART0SendStr("mount filesystem successed!nrnr"); } else { UART0SendStr("mount filesystem failed!nrnr"); } /*格式化磁盘*/ UART0SendStr("正在格式化磁盘,请稍候...nrnr"); //res = f_mkfs(NORFLASH,1,4096);//4096:每簇占用字节数 res = f_mkfs(NORFLASH,0,4096);//4096:每簇占用字节数 if(res == RES_OK) { UART0SendStr("format filesystem successed!nr"); } else { UART0SendStr("format filesystem failed!nr"); } res = f_mount(NORFLASH,NULL); ///////////////////////////////////////////////////////////////////////////////////////////////// res = f_mount(NORFLASH,&fs); /*写文件测试*/ UART0SendStr("write file test......nr"); res = f_open(&FileObject, "test.txt", FA_CREATE_ALWAYS | FA_WRITE); 。。。 } |
|
|
|
有谁知道 文件名是保存在什么地方的 系统上电后直接打开文件 读数据失败是怎么回事
|
|
|
|
你正在撰写答案
如果你是对答案或其他答案精选点评或询问,请使用“评论”功能。
AD7686芯片不传输数据给STM32,但是手按住就会有数据。
621 浏览 1 评论
1962 浏览 0 评论
如何解决MPU-9250与STM32通讯时,出现HAL_ERROR = 0x01U
1068 浏览 1 评论
hal库中i2c卡死在HAL_I2C_Master_Transmit
1487 浏览 1 评论
LL库F030进行3个串口收发,2个串口为232,一个为485,长时间后,会出现串口1停止运行,另外两个正常,只有重启复原
1924 浏览 1 评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2024-11-19 11:40 , Processed in 0.554069 second(s), Total 52, Slave 46 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号