SD Card

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

SD Card

3,107件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rtos on Sat Jun 26 16:03:45 MST 2010
I need to write data to an SD card.  I was thinking of getting this SD Card connector here: http://www.sparkfun.com/commerce/product_info.php?products_id=204

From what I've been researching, it seems that there are at least these two ways I can do this:
1) Write data directly to the card without a file system.  This would not be readable by a PC.
2) Use a file system and write data to a file on the card.  This would be readable by a PC.  Is there a free File System that is FAT16 compatible?

In either case, is there any sample code for the 1343 for option 1 and/or 2?

Thanks.
0 件の賞賛
返信
14 返答(返信)

2,998件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Rob65 on Thu Jan 05 13:03:30 MST 2012

Quote:
MESSAGE("File opened for writing. \n", res) ;

/* Write buffer to file */
// strcpy((char*)buf, "Martin hat's angehaengt\n");
int ll;
if ( (file_write (&filew , 512 , *buffer )) == strlen( buffer ) )

Quote:


What do you think the *buffer in file_write does ?
My C bible tells me this evaluates to one byte being the ASCII value of "M" :eek:

Rob


0 件の賞賛
返信

2,998件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by james on Sun Jan 08 18:27:58 MST 2012
Thanks for the suggestion, i got the buffer fixed, now i can write "strings" into the SD card. But how do i write binaries? for example if i want to write 8, i can convert the 8 to 1000, but sending "1000" would write "1000" in ASCII instead of just 1000.bin.

Could anyone point me how to write binaries in EFSL?

Opps solved, i just change the values to binary, edit and changed back
0 件の賞賛
返信

2,998件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Fri Jan 06 04:07:41 MST 2012
euint8 *buf is a pointer to a buffer (* = pointer) :eek:

This read/write functions use pointers to buffer :rolleyes:

As in the sample you have started with, you could use a buffer like:
char buffer[512];
This is a real array of 512 bytes And you can point to this buffer with your read/ write function.
0 件の賞賛
返信

2,998件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by james on Fri Jan 06 02:42:58 MST 2012
I have notice that the function: euint32 file_write(File *file, euint32 size,euint8 *buf)
means that buf has to be a char, how can i write binary into the sd card? Could someone provide a hint/trick to do this?
0 件の賞賛
返信

2,998件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by james on Thu Jan 05 22:26:58 MST 2012
Oh my, i spend too much time copying and forgotten to use my brain.

Thanks to rob :), its working fine now.

i replaced the write line to :

if(file_write(&file_w,strlen((eint8 *)buffer),buffer) == strlen((eint8 *)buffer))
0 件の賞賛
返信

2,998件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by Ex-Zero on Thu Jan 05 03:34:12 MST 2012
Create a valid buffer, your buffer is nonsense :eek:
0 件の賞賛
返信

2,998件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by james on Thu Jan 05 03:12:29 MST 2012
Hi there, I am trying to save data logged data into sdcard and/or read sdcard value to control leds.

i tried to extend the efsl_demo from red_code_examples but i cant seems to write anything. here is my code:

{
    int8_t res;

    MESSAGE("\nRDB1768 EFSL / microSD card Demonstration\n");
    MESSAGE("=========================================\n");

    MESSAGE("CARD init...");
    if ( ( res = efs_init( &efs, 0 ) ) != 0 ) {
        MESSAGE("failed with %i\n",res);
    }
    else {
        MESSAGE("ok\n");
        MESSAGE("Directory of 'root':\n");
        ls_openDir( &list, &(efs.myFs) , "/");
        while ( ls_getNext( &list ) == 0 ) {
            list.currentEntry.FileName
[LIST_MAXLENFILENAME-1] = '\0';
            MESSAGE( "%s ( %li bytes )\n" ,
                list.currentEntry.FileName,
                list.currentEntry.FileSize ) ;
        }
    }

// This part is provided by red_code_examples and is working perfectly

Here is my code for writing a file

        euint8 *buffer = "1234567" ;
        euint16 e = 0;
        euint8 buffer1[512] ;
        euint16 f ;
        File filew, filer;

        /*Open file for writing */
        if (file_fopen (&filew , &efs.myFs , "read3.txt" , 'a' ) !=0){
        MESSAGE("Could not open file for writing. \n", res ) ;
        return -1;
        }
        else
        MESSAGE("File opened for writing. \n", res) ;

        /* Write buffer to file */
//        strcpy((char*)buf, "Martin hat's angehaengt\n");
        int ll;
        if ( (file_write (&filew , 512 , *buffer )) == strlen( buffer ) )
//        if ( (file_write( &filew, strlen((char*)buf), buf )) == strlen((char*)buf))
        MESSAGE("File written . %d %d \n", file_write, strlen(buffer));
        else
        MESSAGE("Could not write file. \n", res);
        fclose (&filew);

it returns "file written"
It creates a file call "read3.txt" but it doesnt write any thing into it. the file is has 0bytes.
I copied it from a user manual found at efsl.be

I am using a rdb1768v2r4 board and a 2gb micro sd-card formatted to fat16 with 32kb allocation unit size.

Anyone who has used this before please kindly point out what i might have missed. Thank you :)
0 件の賞賛
返信

2,998件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by giamby3000 on Tue May 24 03:16:34 MST 2011

Quote: rompacz
I have an EaBaseBoard with LPC1769 and I need to write an application which will write a file on SD card.
Example provided with the board is very simple and it doesn't operate on files.
Can you help me to extend this example to write/read a file?

simon




I will start the same task next weeks with 1768 Board and I will try to write an SD card. You must have a file system on it.
0 件の賞賛
返信

2,998件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rompacz on Wed May 18 03:26:02 MST 2011
I have an EaBaseBoard with LPC1769 and I need to write an application which will write a file on SD card.
Example provided with the board is very simple and it doesn't operate on files.
Can you help me to extend this example to write/read a file?

simon
0 件の賞賛
返信

2,998件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by NXP_USA on Wed Nov 24 16:01:28 MST 2010

Quote: giamby3000
Good morning, RTOS!
Look at this document:

http://elm-chan.org/docs/mmc/mmc_e.html


If anyone of you has information about examples of code in order to use SD card with LPCXpresso and LPC1100 family, please contact me!

Thank you very much



If you purchase the Embedded Artists baseboard, it includes an SD card socket. If you register the board on EA's website, you will get access to a code library which includes a FAT filesystem to read and write to the SD card.

http://www.embeddedartists.com/products/lpcxpresso/xpr_base.php
0 件の賞賛
返信

2,998件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by cfb on Mon Nov 22 23:13:21 MST 2010

Quote: rtos
1) Write data directly to the card without a file system. This would not be readable by a PC.


You CAN write software to use a PC to access data on a card which doesn't have a file system. There is an outline of some Delphi code and other URLs leading to C code in this discussion:

https://forums.embarcadero.com/thread.jspa?messageID=150471

Your SDCard code on the LPCXpresso can then be as small and as simple as possible with all the hard work being done on the PC.
0 件の賞賛
返信

2,998件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by rtos on Mon Nov 22 20:11:33 MST 2010
This is a really great link.  Thanks!


Quote: giamby3000
Good morning, RTOS!
Look at this document:

http://elm-chan.org/docs/mmc/mmc_e.html


If anyone of you has information about examples of code in order to use SD card with LPCXpresso and LPC1100 family, please contact me!

Thank you very much

0 件の賞賛
返信

2,998件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by giamby3000 on Thu Nov 11 01:06:26 MST 2010
Good morning, RTOS!
Look at this document:

http://elm-chan.org/docs/mmc/mmc_e.html


If anyone of you has information about examples of code in order to use SD card with LPCXpresso and LPC1100 family, please contact me!

Thank you very much
0 件の賞賛
返信

2,998件の閲覧回数
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by CodeRedSupport on Sun Jun 27 04:21:32 MST 2010
Here are a couple of  LPC17 related things that you might want to look at - should be fairly simple to transfer over to LPC13...


[LIST]
[*]AN10916 FAT library EFSL and FatFs port on NXP LPC1700
[/LIST]
[INDENT]http://ics.nxp.com/support/documents/microcontrollers/
[/INDENT]
[LIST]
[*]Embedded Filesystems Library Example
[/LIST]
[INDENT]http://support.code-red-tech.com/CodeRedWiki/RDB1768cmsisExampleProjects
[/INDENT]Regards,
CodeRedSupport
0 件の賞賛
返信