Use of Fatfs on a TMS320F28335

Guest #3364049
Rate this post
• ▲ useful
▼ not useful
Hi,
I have a little problem with the use of Fatfs on my DSP. In fact, 
opening a file on a microSD doesn't work...:(

Smple code:

//...Variable initializations...


// Mount return FR_OK
f_mount(&FatFs, "0:", 0);

// Opening fails...
f_open(&File, "Tes.txt", FA_OPEN_EXISTING | FA_READ);
// It returns FR_NOT_READY because it the disk_initialize function
// dosn't work and satisfy the condition STA_NO_INT which return 
//FR_NOT_READY...


So, I have no more idea where I could search. The micro_SD is a Kingston 
(4GB) class 10 which is inserted in a SD adaptater which is linked to 
the DSP. On my computer or mobile phones everything is OK on the card, 
so it's not the health of the card but what ? What can do this kind of 
error ?
The clock speeed of SPI is 300kHz so it's not really great to cause 
issue...
I give you the diskio.c file which is the only one I change to adapt on 
my target. If somebody could understand something and know the FatFs 
module, I really thank him/her to help me to understand...
Attached files:
Admin #3364136
Rate this post
• ▲ useful
▼ not useful
koko wrote:
> Mount return FR_OK
> f_mount(&FatFs, "0:", 0);

f_mount does not actually communicate with the card, so this doesn't 
help ypi.

Did you set up your SPI interface correctly? Do the SPI read commands 
return something sensible? One of the most common errors is to set the 
clock phase and polarity incorrectly, so double check if yours is set 
correctly; try out all possibilities if necessary. If that doesn't solve 
the problem, try a different card.
Guest #4604756
Rate this post
• ▲ useful
▼ not useful
The problem is size of char, which is 16 bits for TMS320F28x. So, the 
comparisons that include an unsigned char variable and a hex constant 
will fail. For the disk_initialize function, it fails when wait_ready 
function is called, since variable res never becomes equal to 0xFF.

BYTE wait_ready (void)
{
    BYTE res;


    Timer2 = 50;    /* Wait for ready in timeout of 500ms */
    rcvr_spi();
    do
        res = rcvr_spi();
    while ((res != 0xFF) && Timer2); // <--- res != 0xFF fails

    return res;
}

In order to access single byte value, __byte intrinsic function can be 
used as the following:
__byte(&res,0) != 0xFF

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.