ARM7S: ChaN’s FatFS write problem

OP #1377385
Rate this post
• ▲ useful
▼ not useful
Hello,


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 
headache.

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.

Christian

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

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.