attempting SD card on K60 without RTOS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

attempting SD card on K60 without RTOS

1,251 Views
arunkumar1989
Contributor I

Hello Everyone,

I am attempting to get an SD card working without using an RTOS.

I am stuck at a few points and need some help.

I have attached the project with this thread.

Firstly when opening  file using FAT1_open(),it returns FR_OK,but i do not see the file created on my computer.

Secondly,

FAT1_close() always gives error 0x01, FR_DISK_ERR for no reason, am i missing something else here?

Thanks in advance,

Arun Kumar

0 Kudos
8 Replies

939 Views
BlackNight
NXP Employee
NXP Employee

Hi Arun,

there is no project attached?

Erich

0 Kudos

939 Views
arunkumar1989
Contributor I

Opps here it is

0 Kudos

939 Views
BlackNight
NXP Employee
NXP Employee

Hi Arun,

thanks for posting the project. I assume you are using CodeWarrior v10.6 with my latest components from SourceForge?

I see that you had a .metadata (workspace) folder inside your project: that's clearly something not good (don't put a workspace into your project folder).

When compiling, I noticed this warning:

Description    Resource    Path    Location    Type

ignoring #pragma jump_switch  [-Wunknown-pragmas]    display.c    /sdcard1/Sources    line 261    C/C++ Problem

but this one is a real problem:

Description    Resource    Path    Location    Type

passing argument 1 of 'f_mount' from incompatible pointer type [enabled by default] passing argument 2 of 'f_mount' makes pointer from integer without a cast [enabled by default]    sdcard.c    /sdcard1/Sources    line 19    C/C++ Problem

You pass a pointer to a file (FILE fp), and not a pointer to a FATFS fs. For sure, this will be a big problem the memory blocks/size behind these are different.

So can you fix this?

The other problem with your project I see is this: you are using the Timeout component, but I don't see that you feed the timeout every 10 ms (as specified in the properties) from a 10 ms timer interrupt or similar: you need to call TMOUT1_AddTick() every 10 ms, e.g. from Events.c.

Please have a look at this FatFS bare-metal (no OS) project on GitHub:

mcuoneclipse/Examples/TRW-K60N512/TWR-K60N512_FatFS_BM at master · GitHub

I hope this helps,

Erich

0 Kudos

939 Views
arunkumar1989
Contributor I

Yes sir, i am using CW 10.6

I changed FILE fp to FAFTS fp;

I checked out the bare metal project,it gives me error on these lines

[code]

while(!FAT1_isDiskPresent()) {

[/code]

Description    Resource    Path    Location    Type

too few arguments to function 'FAT1_isDiskPresent'    Application.c    /TWR-K60N512_FatFS_BM/Sources    line 79    C/C++ Problem

[code]

FAT1_mount(0, &fileSystemObject); /* mount file system */

[/code]

Description    Resource    Path    Location    Type

macro "FAT1_mount" requires 3 arguments, but only 2 given 'FAT1_mount' undeclared (first use in this function)    Application.c    /TWR-K60N512_FatFS_BM/Sources    line 83    C/C++ Problem

0 Kudos

939 Views
BlackNight
NXP Employee
NXP Employee

Yes, I'm sorry, I missed to make the changes needed for CW for MCU10.6. I have now commited the changes:

https://github.com/ErichStyger/mcuoneclipse/commit/1ece772a76c38a46c4fcaa3f8a49b8fcbaf4343f

Erich

0 Kudos

939 Views
arunkumar1989
Contributor I

Hello Erich,

I am stuck with this problem and was wondering if you could help me out,

Is it possible to store a file in a particular address of my choosing in an sd card,that way i do not need to know the the file name for any operation like file deletion or file renaming?

Also in the "FAT1_getfree(path, nclst, fs)" function does nclst gives the size in Bytes?

Thanks in advance,

Arun

0 Kudos

939 Views
BlackNight
NXP Employee
NXP Employee

Hi Arun,

the file system manages the low level blocks and allocation, so you cannot put a file at a specifiic address if using the file system. You would need to use the SD card in raw/block mode instead (but then you are not using the file system).

Using the file system, you do not need to know the file name for the delete operation: you need the file handle. But of course you need the file name/path to open the file to get the handle.

As for getfree() (and others), I recomment to have a look at the FatFs web site, or here FatFs - f_getfree

Erich

0 Kudos

939 Views
arunkumar1989
Contributor I

Hello sir,

I am able to create a file in the SD card now, Thank you so much.

The timer interrupt did the trick .

Arun

0 Kudos