Jump to content
43oh

[Energia Library] Petit FatFS SD Card Library


Recommended Posts

  • 1 month later...
  • Replies 148
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Hello,   This is a port of ChaN Petit FatFS SD library targeted to low RAM microcontrollers and offers a minimal FAT implementation, with limited write support. For more details see http://elm-chan.

A small update: - all config settings in one file - pffconf.h - a soft SPI driver ( shuftIn/shiftOut ) that can be enabled in pffconf.h. It defaults on HW SPI pins, but these can be changed using Fa

Hi, i just wanted to report that the library won't compile with Energia release 0101E0011 and the F5529 Launchpad because "DIR" is already defined in \energia-0101E0011\hardware\tools\msp430\msp430\in

Posted Images

If the SD-card reader features card detection, here's the code for a basic implementation:

#define CARD_DETECT PA_2

void setup()
{
  pinMode(RED_LED, OUTPUT);  
  pinMode(GREEN_LED, OUTPUT);
  pinMode(CARD_DETECT, INPUT_PULLUP);
}

void loop()
{
  if (digitalRead(CARD_DETECT)) {
    digitalWrite(RED_LED, HIGH);
    digitalWrite(GREEN_LED, LOW);
  } else {
    digitalWrite(RED_LED, LOW);
    digitalWrite(GREEN_LED, HIGH);
  }
  delay(500);  
}

The green LED lights on when a card is inserted, otherwise the red LED is on.

Link to post
Share on other sites
  • 2 weeks later...

Hi, i just wanted to report that the library won't compile with Energia release 0101E0011 and the F5529 Launchpad because "DIR" is already defined in \energia-0101E0011\hardware\tools\msp430\msp430\include\msp430f5529.h line 3900: 

/* USBCTL Control Bits */
#define DIR            (0x0001)  /* USB - Data Response Bit */

renaming all "DIR" references in the Petit-FATFS library and examples to "_DIR" works as a workaround.

 

regards, Nick

Link to post
Share on other sites
  • 4 weeks later...

@@calinp

 

Was just wondering if there is a list of return codes and their meaning for this library.

 

eg. Fail with rc=6

 

I've looked and it just seems to elude me completely.

 

Cheers

 

PTB

@@PTB

In src/ff.h

typedef enum {
    FR_OK = 0,                /* (0) Succeeded */
    FR_DISK_ERR,            /* (1) A hard error occurred in the low level disk I/O layer */
    FR_INT_ERR,                /* (2) Assertion failed */
    FR_NOT_READY,            /* (3) The physical drive cannot work */
    FR_NO_FILE,                /* (4) Could not find the file */
    FR_NO_PATH,                /* (5) Could not find the path */
    FR_INVALID_NAME,        /* (6) The path name format is invalid */
    FR_DENIED,                /* (7) Access denied due to prohibited access or directory full */
    FR_EXIST,                /* (8) Access denied due to prohibited access */
    FR_INVALID_OBJECT,        /* (9) The file/directory object is invalid */
    FR_WRITE_PROTECTED,        /* (10) The physical drive is write protected */
    FR_INVALID_DRIVE,        /* (11) The logical drive number is invalid */
    FR_NOT_ENABLED,            /* (12) The volume has no work area */
    FR_NO_FILESYSTEM,        /* (13) There is no valid FAT volume */
    FR_MKFS_ABORTED,        /* (14) The f_mkfs() aborted due to any parameter error */
    FR_TIMEOUT,                /* (15) Could not get a grant to access the volume within defined period */
    FR_LOCKED,                /* (16) The operation is rejected according to the file sharing policy */
    FR_NOT_ENOUGH_CORE,        /* (17) LFN working buffer could not be allocated */
    FR_TOO_MANY_OPEN_FILES,    /* (18) Number of open files > _FS_SHARE */
    FR_INVALID_PARAMETER    /* (19) Given parameter is invalid */
} FRESULT;
Link to post
Share on other sites
  • 2 months later...
  • 1 month later...

For who keep having the rc=6 problem with a sdcard holder pcb (bought from ebay), try to change mosi and miso position. I guess that the indications on the SD card holder are indications for the launchpad connections, So you have to put input with input (miso with miso) and not input with output.

Link to post
Share on other sites

For who keep having the rc=6 problem with a sdcard holder pcb (bought from ebay), try to change mosi and miso position. I guess that the indications on the SD card holder are indications for the launchpad connections, So you have to put input with input (miso with miso) and not input with output.

Contrary to UART, SPI does not have such an ambiguity.

 

In UART there is a Tx and an Rx pin, which mean one pin is receiving and one pin is transmitting. To have two devices chatting to eachothter, one should have the transmitting pin from party A connected to the receiving pin of party B and vice versa.

 

In SPI on the other hand, the pins are explicitly described by their role. The Master In, Slave Out (MISO) pin is the receiving pin on the master, but the transmitting pin on the slave. In the same fashion the Master Out, Slave In (MOSI) is the transmitting pin on the master but the receiving pin on the slave. The only thing to figure out now is which party is the slave and which the master. This is (in my view) obvious; the controller is the master, the card is the slave.

Link to post
Share on other sites

Has anyone tried to implement a create file function in the Petit FatFs?

I tried to use the FatFs in the g2553, but there is not enough memory.  

@@aimepinto You cannot create a file in Petite FatFs. You have to create it externally on a PC and write to the file on the chip.

FatFs is too large for the 2553. You may try running it on the higher end Launchpads.

Link to post
Share on other sites
  • 3 months later...

Hello, everyone!

 

So I've connected SD card to launchpad (g2553). When I'm trying to execute PFatFsFileTest I'll get something like: 

Press button to start...

 
Failed with rc=6
 
The only file on sdcard is "SD card test.txt", but I can't open it (probably because of spaces in the filename? or mb I did something wrong. idk). And... I've soldered sdcard, so I can't write any new file in there T_T Is it possible to do smth to make things work or I need to unsolder it first?
 

Thanks a lot in advance.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...