2015-05-21 08:59 AM
Hello
I use STM3210e-eval.I want to implement Fatfs for the SDcard (using SDIO interface)Thats work !I can create a file or a directory, read a file, write in the file, delete file, rename file.the problem is that: when I want to write multiples line in the file. Just one line is written in the file then the system go in the infinite loop of Default_Handler !!to write multiples line, I tried this two methods (one using f_pritnf and the other using f_write):1) ''in a loop''res = f_mount(0, &Fatfs);res = f_open(&Filsd, ''0:LOG.TXT'', FA_WRITE | FA_OPEN_ALWAYS);f_printf(&FilSD, ''ABCD\n'');f_close(&Filsd);f_mount(0, NULL);2) '' in a loop''writeTextBuff[]= ''ABCD\n''res = f_mount(0, &Fatfs);res = f_open(&Filsd, ''0:LOG.TXT'', FA_WRITE | FA_OPEN_ALWAYS);res = f_lseek(&Filsd, f_size(&Filsd));bytesToWrite =sizeof(writeTextBuff) - 1;res = f_write(&Filsd,writeTextBuff,bytesToWrite, &bytesWritten );f_close(&Filsd);f_mount(0, NULL);this first time, the code is executed normally, but the second loop the system go in Default_Handler at f_printf in method 1. and at f_lseek in method 2Any Help please ?Thank you #stm32 #dma #fatfs #sdio #sd2015-05-21 09:09 AM
Default_Handler suggests that you're getting an interrupt you're not servicing with a real routine.
Do you have a Hard Fault Handler?I'm not sure of the wisdom of standing up and tearing down the file system context is this fashion, and the lack of any error handling or review of the return codes.I would suggest you look very carefully about how your lower level code tears down the interface, and how the initialization code deals with being called multiple times.2015-05-21 09:23 AM
2015-05-21 09:29 AM
Then you really need to look at what the processor is faulting on, and fix that.
Get a proper Hard Fault Handler, see the Joesph Yiu examples (books/online)Identify where in your code it fails. Whether it's an errant pointer or a read/write to memory that doesn't exist.You might also want to zero out the file system and file handle structures before you start each iteration, in case there are some values left in there that are no longer valid.