我手上有几个项目因为要使用到在SDRAM中建立FatFS,首先在SPI FLASH中的文件拷贝到SDRAM中的FatFS,因为数据操作特别频繁,因此设定在一定时间段后将SDRAM中的文件拷贝到SPI Flash。 测试环境:STM32F429IGT6+W9825G6KH的SDRAM 软件环境:STM32CubeMX 1.8 单独测试429驱动SDRAM都是一切正常的,在加载FatFS文件系统以后,执行以下操作就出现代码标注红色地方: 打开文件就一直提示的是没有文件系统,而我在初始化FatFS之后,去观察我SDRAM首地址0xC0000000之后的512个字节,所有数据全部为0,目前不知道问题出在哪里,恳请大家帮忙分析分析? printf("\r\n ****** FatFs Example ******\r\n\r\n"); /*##-1- Register the file system object to the FatFs module ##############*/ retSD = f_mount(&fs, "0:", 0); if(retSD) { printf(" f_mount error : %d \r\n",retSD); Error_Handler() ; } else { printf(" mount sucess!!! \r\n"); } retSD = f_fdisk(0,plist,work) ; if( retSD ) { printf(" f_fdisk error : %d \r\n",retSD); Error_Handler() ; } else { printf(" f_fdisk sucess!!! \r\n"); } retSD = f_mkfs("0:",FM_ANY,2048,work,sizeof work) ; if(retSD) { printf(" mkfs error : %d \r\n",retSD); Error_Handler() ; } else { printf(" mkfs sucess!!! \r\n"); } retSD = f_mount(NULL, "0:", 1); retSD = f_mount(&fs, "0:", 1); /*##-2- Create and Open new text file objects with write access ######*/ retSD = f_open(&fil, filename, FA_CREATE_NEW | FA_WRITE | FA_READ ); //在这里就提示没有文件系统,而我调试观测SDRAM的首地址,发现在首地址这里之后的512字节的数据全是0x00. if(retSD) { printf(" open file error : %d\r\n",retSD); } else { printf(" open file sucess!!! \r\n"); } /*##-3- Write data to the text files ###############################*/ retSD = f_write(&fil, wtext, sizeof(wtext), (void *)&byteswritten); if(retSD) { printf(" write file error : %d\r\n",retSD); } else { printf(" write file sucess!!! \r\n"); printf(" write Data : %s\r\n",wtext); } /*##-4- Close the open text files ################################*/ retSD = f_close(&fil); if(retSD) { printf(" close error : %d\r\n",retSD); } else { printf(" close sucess!!! \r\n"); } /*##-5- Open the text files object with read access ##############*/ retSD = f_open(&fil, filename, FA_READ); if(retSD) { printf(" open file error : %d\r\n",retSD); } else { printf(" open file sucess!!! \r\n"); } /*##-6- Read data from the text files ##########################*/ retSD = f_read(&fil, rtext, sizeof(rtext), (UINT*)&bytesread); if(retSD) { printf(" read error!!! %d\r\n",retSD); } else { printf(" read sucess!!! \r\n"); printf(" read Data : %s\r\n",rtext); } /*##-7- Close the open text files ############################*/ retSD = f_close(&fil); if(retSD) { printf(" close error!!! %d\r\n",retSD); } else { printf(" close sucess!!! \r\n"); } /*##-8- Compare read data with the expected data ############*/ if(bytesread == byteswritten) { printf(" FatFs is working well!!!\r\n"); } retSD=f_mount(0, "0", 0); |
评分
查看全部评分