Forum: ARM programming with GCC/GNU tools ARM7S: ChaN’s FatFS write problem

von Chris B. (chris301)

Rate this post
0 useful
not useful

I’m trying to use ChaN’s FatFS with the interface provided by Martin 
Thomas on my AT91SAM7S256, but the “data write” part gives me a 

Before going into details, first of all thanks very much to ChaN and 
Martin for their work, I really appreciate it.

OK, besides FatFs I have FreeRTOS installed, one main task and one 
“write to SD-card” task. The task structure seems to work, no problems 
in the past. In Martin’s interface I have deactivated DMA, since for 
some reason it didn’t work. I didn’t want to dig deeper, my application 
also works without DMA.
Using FatFS to create, open and close files works perfectly. The only 
problem is when I want to write data to the SD-card continuously (not 
only one sector). In many cases it works, but every now and then various 
interrupts fire (spurious, DABT, UDEF etc).

I have used Martin’s example application as basis, my test code looks 
somewhat like that:

BYTE buff_test[4*2] _attribute_ ((aligned (4)));
UINT byte_written, byte_len;
unsigned int i = 0;

res = f_open(&File1, FileName, FA_OPEN_ALWAYS | FA_WRITE);
res2 = f_lseek(&File1, File1.fsize);

(Continuous loop until “stop” button is pressed)
for (i=0; i<=3;i++) buff_test[i]=i;
byte_len = sizeof(buff_test);
res3 = f_write(&File1, buff_test, byte_len, &byte_written);

res4 = f_close(&File1);
f_mount(0, NULL);

I must admit that I have no deeper knowledge of the _attribute_ 
command. In case this is the reason for my code to crash, do you have 
any sample code to show how to input “integer”- and “long”-type data 
correctly into above described array structure?

Once this problem is fixed, I want both tasks to access the 
SPI-interface to communicate with different external devices.


P.S.: I have to apologize in advance in case somebody answers too 
quickly: I will be away for the next 8 days.


Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]

Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.