Tridon 0 Posted March 11, 2015 Share Posted March 11, 2015 How to create a file using the Petit FatFs library?I don't quite how to create a file Quote Link to post Share on other sites
bluehash 1,581 Posted March 13, 2015 Share Posted March 13, 2015 How to create a file using the Petit FatFs library? I don't quite how to create a file @@Tridon Welcome to the forum. Look at the "Hardware Preparation" section in this sd-card interface walkthrough. Tridon 1 Quote Link to post Share on other sites
bluehash 1,581 Posted March 13, 2015 Share Posted March 13, 2015 Hello, I'm also getting the messgage Failed with rc=6, please someone help us out! Make sure you init the file system first using the "di" command. regioiger 1 Quote Link to post Share on other sites
Tridon 0 Posted March 17, 2015 Share Posted March 17, 2015 (edited) @@Tridon Welcome to the forum. Look at the "Hardware Preparation" section in this sd-card interface walkthrough I wanted to ask how to do I write a data into the SD card as the read write function is not the same as arduino here is an example code where i want to record the temperature Wire.requestFrom(TMP275Address, (byte)2); byte tempHighByte = Wire.read(); byte tempLowByte = Wire.read(); float temperature = word( tempHighByte, tempLowByte)/256.0; lcd.print(temperature); int b = 28; if (temperature< { digitalWrite(5,LOW); digitalWrite(6,LOW); } if (temperature >= b, temperature++) { digitalWrite(5,HIGH); digitalWrite(6,HIGH); } rc = FatFs.open("Temperature.txt"); FatFs.write(temperature); Do I directly write into SD card with the instruction above or am I missing something? Edited March 17, 2015 by bluehash [Admin] Please use code tags next time. Quote Link to post Share on other sites
regioiger 1 Posted March 31, 2015 Share Posted March 31, 2015 Hello, I'm also getting the messgage Failed with rc=6, please someone help us out! I'm use a pull up resistor (10Kohm or similar) in SCK pin and no more Failed with rc=6. I don't know the reason for this but working on a TIVA Launchpad. bluehash 1 Quote Link to post Share on other sites
AbhishekBaghel 0 Posted June 22, 2015 Share Posted June 22, 2015 Hi, Im working with msp432 launchpad.There is and error in SPI library.Plese tell what modifications are required to be done for msp432 lauchpad. Quote Link to post Share on other sites
bluehash 1,581 Posted June 22, 2015 Share Posted June 22, 2015 Hi, Im working with msp432 launchpad.There is and error in SPI library.Plese tell what modifications are required to be done for msp432 lauchpad. I'm writing a tutorial on getting the MSP432 Launchpad working with the SDcard reader with full fatFS. I'm almost there. dubnet and PTB 2 Quote Link to post Share on other sites
AbhishekBaghel 0 Posted June 29, 2015 Share Posted June 29, 2015 I'm writing a tutorial on getting the MSP432 Launchpad working with the SDcard reader with full fatFS. I'm almost there. msp432_launchpad_sdCard_fatfs.jpg Hi, Is your tutorial ready??My college project is stuck from two weeks due to this please help... Quote Link to post Share on other sites
libeo1994 0 Posted July 29, 2015 Share Posted July 29, 2015 how to create file by msp430 not pc ? Thank you Quote Link to post Share on other sites
Dale 0 Posted September 18, 2015 Share Posted September 18, 2015 Hi there, I also have a data logging project and need 128GB+ of data storage. Post #54 reported a working 8 GByte SDHC. Does anyone know if Card Reader and Petit FatFS would work with SDXD? Thanks! Dale Quote Link to post Share on other sites
blannoy 1 Posted October 1, 2015 Share Posted October 1, 2015 Hi, I'm trying to use an SDCard as a datalogger. I can write to the card using the sample. I want to append the data and for that I'm using a 4 byte header in the file. It seems that when I want to update the header after a logging session all the data is missing from the file as well. What am I doing wrong: ... rc = FatFs.open("T_WRITE.TXT"); if (rc) die(rc); char buffer[4]; rc = FatFs.read(buffer, sizeof(buffer), &br); /* Read a chunk of file */ if (rc || !br) die(rc); /* Error or end of file */ for (uint16_t i = 0; i < br; i++){ fileIndex.myByte[i]=buffer[i]; } rc = FatFs.lseek(fileIndex.myLong+4); if (rc) die(rc); for (uint16_t i=0;i<20;i++) { // simulate write of data int val[4]; val[0]=random(2000); val[1]=random(2000); val[2]=random(2000); val[3]=random(2000); String reading; reading+=val[0]; reading+=" "; reading+=val[1]; reading+=" "; reading+=val[2]; reading+=" "; reading+=val[3]; reading+="\n\t"; char buf[reading.length()]; reading.toCharArray(buf, reading.length()); rc = FatFs.write(buf, reading.length(), &bw); // update index value fileIndex.myLong+=reading.length(); if (rc) break; } if (rc) die(rc); rc = FatFs.write(0, 0, &bw); //Finalize write if (rc) die(rc); //update fileindex rc=FatFs.lseek(0); rc = FatFs.write(fileIndex.myByte,4,&bw); if (rc) die(rc); rc = FatFs.write(0, 0, &bw); //Finalize write if (rc) die(rc); rc=FatFs.close(); if (rc) die(rc); Serial.println(); Serial.print("Test completed."); regards Bob hemangjoshi37a 1 Quote Link to post Share on other sites
bluehash 1,581 Posted October 1, 2015 Share Posted October 1, 2015 Not sure what you are trying to do.. but there is an example here: http://elm-chan.org/fsw/ff/pf/lseek.html hemangjoshi37a 1 Quote Link to post Share on other sites
blannoy 1 Posted October 2, 2015 Share Posted October 2, 2015 Not sure what you are trying to do.. but there is an example here: http://elm-chan.org/fsw/ff/pf/lseek.html I don't want the data to be overwritten every time I open the file for logging. So that's why I thought to add the current size of the data as a 4byte header of the file that I read every time the file is opened. That's the first lseek. Then I write the data and keep track of the size of the data output to the file. After the data is logged I have to update my file header. So I do an lseek(0) to rewind. There things seem to go wrong because I end up with an updated header and an emtpy file. If I do not update the file header the data is in the file. It seems that the data is not written to the sdcard before the rewind. Quote Link to post Share on other sites
frankgbucio 0 Posted March 11, 2016 Share Posted March 11, 2016 Hi I Quote Link to post Share on other sites
spineless 2 Posted October 5, 2016 Share Posted October 5, 2016 Has anyone tested the code uploaded by CalinP (see #15 Feb 21, 2013) recently? I am using Energia 1.6.10E18 running on a MAC OS X. All I did was the following: 1. Downloaded the code and place the entire folder into the Energia folder. 2. I then opened the example "PFATFsFileTest" and clicked on "verify" to make sure it would compile....and of course it did not. Here is the debug info. In file included from /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/pfatfs.h:23:0, from /Users//Documents/Energia/PFatFs/examples/PFatFsFileTest/PFatFsFileTest.ino:9: /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/utility/pff.h:57:3: error: expected unqualified-id before numeric constant /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/utility/pff.h:57:3: error: expected ')' before numeric constant /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/utility/pff.h:95:25: error: expected primary-expression before ',' token /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/utility/pff.h:95:27: error: expected primary-expression before 'const' /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/utility/pff.h:95:38: error: expression list treated as compound expression in initializer [-fpermissive] /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/utility/pff.h:96:25: error: expected primary-expression before ',' token /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/utility/pff.h:96:34: error: expected primary-expression before '*' token /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/utility/pff.h:96:35: error: expected primary-expression before ')' token /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/utility/pff.h:96:35: error: expression list treated as compound expression in initializer [-fpermissive] In file included from /Users/chrispinter/Documents/Energia/PFatFs/examples/PFatFsFileTest/PFatFsFileTest.ino:9:0: /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/pfatfs.h:37:11: error: expected unqualified-id before numeric constant /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/pfatfs.h:37:11: error: expected ')' before numeric constant /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/pfatfs.h:81:19: error: expected identifier before '(' token /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/pfatfs.h:81:19: error: expected ')' before numeric constant /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/pfatfs.h:81:19: error: expected ')' before numeric constant /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/pfatfs.h:81:19: error: expected ';' at end of member declaration /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/pfatfs.h:81:19: error: expected unqualified-id before numeric constant /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/pfatfs.h:84:19: error: expected identifier before '(' token /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/pfatfs.h:84:19: error: expected ')' before numeric constant /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/pfatfs.h:84:19: error: expected ')' before numeric constant /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/pfatfs.h:84:19: error: expected ';' at end of member declaration /Users//Documents/Energia/libraries/SDCardTutorialWithEnergia/pfatfs.h:84:19: error: expected unqualified-id before numeric constant PFatFsFileTest:17: error: expected unqualified-id before numeric constant PFatFsFileTest:17: error: expected ')' before numeric constant /Users//Documents/Energia/PFatFs/examples/PFatFsFileTest/PFatFsFileTest.ino: In function 'void loop()': PFatFsFileTest:108: error: 'dir' was not declared in this scope exit status 1 expected unqualified-id before numeric constant .... I think the current version of Energia might not like the DIR or FILE. These variables are causing me grief. Is there a bug to fix, work around, or a better way to do this? Thanks, Spineless Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.