Jump to content
43oh

PetiteFS FATfs SDCard USCI code


Recommended Posts

  • Replies 144
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

Edit: July 6th, 2014 Please also note that Pabigot maintains BSP430 which has an example for the msp430. He also tracks any changes done to the ElmChan library with patches made to the example. Refer

I went ahead and tested the booster pack and added the write support in the attached zip file. You should take a look at the Petit FatFS documentation regarding the write limitations. PetiteFS only

I took a look at the software serial code - I'm not seeing any issues with gutting it and using hardware UART unless I'm missing something obvious.  I'm not seeing anything that sets anything affectin

Posted Images

  • 2 weeks later...

Friends

I need some help,using the petitFAT library, I managed to do the implementation in my application, but I need your help to get write to the memory card thing that I am not able to do. Can anyone help me? 

Did you follow the tutorial here. You need to create the file on the card first.

Link to post
Share on other sites

Hello Bluehash, I follow the tutorial,  and everything seems to be ok, the file was created earlier on the card. 

The problem is that does not write on the card, I shared all my file and picture of what happens to me, hoping to get some help, that would allow me to solve the problem.
Link to post
Share on other sites
  • 2 months later...

@@bluehash I try to write my data into SD-card, but i have a problem. It overwrite the old-data in sd card, i try to using "pf_lseek(ofs);" function, but nothhing change and i can't control the pointer where i start to write the first data. And further, i can read- write data correctly without control the first byte location. Where is the mistake? Please help me!

And my project in the attach file.

Thank you!

test sd card 3.rar

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

@@bluehash I try to write my data into SD-card, but i have a problem. It overwrite the old-data in sd card, i try to using "pf_lseek(ofs);" function, but nothhing change and i can't control the pointer where i start to write the first data. And further, i can read- write data correctly without control the first byte location. Where is the mistake? Please help me!

And my project in the attach file.

Thank you!

Help me, please! :sad:

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

Hi ,
I testing this library with the MSP430FR4133 LP and my own code.. the Read and Write function is working fine, But the Thing is while writing to a file only Five characters is getting written to the file i.e if I write KAMALESH only KAMAL is written to the file. Can you Help me with this issue..

Source Code


#include <SPI.h>
#include <pfatfs.h>
#include <pffconf.h>

#define cs_pin      8             // chip select pin 
#define read_buffer 128             // size (in bytes) of read buffer 
#define LOG_DELAY   5000          // 5000ms -> 5sec

unsigned long int bw, br;//, i;
char buffer[read_buffer];
int rc;
DIR dir;        /* Directory object */
FILINFO fno;      /* File information object */

uint32_t ui32_ReadTemp = 0;
uint8_t StringLength = 0;
char buf[30];
uint32_t counter = 0;
uint32_t AccStringLength = 0;

void setup()
{
   Serial.begin(9600);                // initialize the serial terminal
   analogReference(INTERNAL1V5);
   FatFs.begin(cs_pin);              // initialize FatFS library calls
   Serial.print("\n\n\nMSP430 Logger \n\r"); 
   Serial.println("Type the String");
}
         
/* Stop with dying message */         
void die ( int pff_err  )
{
   Serial.println();
   Serial.print("Failed with rc=");
   Serial.print(pff_err,DEC);
   for (;;) ;
}

void printDec(uint32_t ui) 
{
   Serial.print(ui/10, DEC);
   Serial.print(".");
   Serial.print(ui%10, DEC);
}

/*-----------------------------------------------------------------------*/
/* Program Main                                                          */
/*-----------------------------------------------------------------------*/
void loop()
{
if(Serial.available())
{
  String src = Serial.readString();

  if(src.indexOf("R") != -1)
  {
      rc = FatFs.open("datalog.txt");
      if (rc) die(rc);
      delay(100);
      for (;;) {
      rc = FatFs.read(buffer, sizeof(buffer), &br);  /* Read a chunk of file */
     if (rc || !br) break;      /* Error or end of file */
     Serial.println(buffer);
       rc = FatFs.close();  //Close file
     if (rc) die(rc);
     }
  }
  else
  {
    rc = FatFs.open("datalog.txt");
    if (rc) die(rc);
   delay(100);
  char* msg = string2char(src);
      StringLength =  strlen(msg);
      Serial.println(msg);  
Serial.print("Size:");
Serial.println(StringLength);
      rc = FatFs.write(msg, StringLength,&bw);
      if (rc) die(rc);
      // rc = FatFs.write(0, 0, &bw);  //Finalize write
      // if (rc) die(rc);
       rc = FatFs.close();  //Close file
            if (rc) die(rc);
       Serial.println("ADDED");
    }
  }
}

char* string2char(String command)

  if(command.length()!=0)
  { 
    char *p = const_cast<char*>(command.c_str()); 
    return p;     
  }
}

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