2019-06-09 10:55 PM
hi Im using stm32f105rb mcu to read files from usb using fatfs libraries and i am able to read upto 17 files simultaneously more than that will shoot a disk error. what will be the root cause and is it possible to read more then 50 files simultaneously pls help...
2019-06-09 11:35 PM
Check things like stack, buffers and setting in FatFs.
Make sure you have space for each file instance.
Instrument DISKIO layer to see what's happening there.
I could see this churning the FAT Table a lot, but that could be managed.
You need 50 files open why? Surely a more rational solution can be found?
2019-06-10 03:33 AM
thanks for response... im reading file from usb and storing in a buffer and clearing it and again open file from usb. Here not exact 50 files just for a example. i need to read files continuously without disk error
void usb_data(char * fname)
{
int *fss;
fss = USBH_malloc(sizeof (fs));
memset(file_buffer,0,sizeof(file_buffer));
res = f_open(&fil, fname,FA_OPEN_EXISTING | FA_READ);
if (res!=FR_OK)
{
HAL_UART_Transmit(&huart1,file_err,sizeof(file_err),100);
}
else{
HAL_UART_Transmit(&huart1,file_open,sizeof(file_open),100);
}
HAL_Delay(50);
res=f_read(&fil,file_buffer,f_size(&fil),&test);
if (res!=FR_OK)
{
HAL_UART_Transmit(&huart1,read_error,sizeof(read_error),100);
}
else{
HAL_UART_Transmit(&huart1,"\r\n read success ",20,100);
}
HAL_UART_Transmit(&huart1,"\r\n file closed...",20,100);
for(vall=0;vall<=sizeof(file_buffer)-1;vall++)
{
buf=0;
if(file_buffer[vall]==0x24)
{
for(va=vall;va<=sizeof(file_buffer)-1;va++)
{
myBuff[buf]=file_buffer[va];
HAL_UART_Transmit(&huart1,&myBuff[buf],1,100);
if(myBuff[buf]==0x0a)
{
break;
}
buf++;
}
}
}
f_close(&fil);
USBH_free(fss);
2019-06-10 03:56 AM
Ok, so forget FATFS for a moment and diagnose why the read sector code fails with an error.