roadrunner84 466 Posted October 29, 2014 Share Posted October 29, 2014 You can use SD cards, but you must write on-the-fly. Since (as stated) you cannot cache a sector (which are 512 bytes for almost all cards), since the msp430g2553 has only 256 bytes of RAM. Quote Link to post Share on other sites
stasundr 0 Posted October 29, 2014 Share Posted October 29, 2014 Sorry, I still don't get it. Is it possible to write anything on SD card with msp430g2553? In this case I will store every log string in a separate file. Or maybe I need to find SD card with <512 bytes sectors? I'm currently using very old 16mb Toshiba card. Mb it is the right one... Quote Link to post Share on other sites
roadrunner84 466 Posted October 29, 2014 Share Posted October 29, 2014 Sorry, I still don't get it. Is it possible to write anything on SD card with msp430g2553? In this case I will store every log string in a separate file. Or maybe I need to find SD card with <512 bytes sectors? I'm currently using very old 16mb Toshiba card. Mb it is the right one... SD cards with sectors under 512 bytes do not exist, some with 1024 bytes or 2048 bytes sectors exist, albeit somewhat out of spec (for the 2048 bytes version). The only real way to write data to the SD card is to prepare the card in a PC to have a hard sequential order of sectors within one file. Then write to that sector in a sequential way. You will keep the writing cycle open this way so you can push more data to it before finishing the write cycle. This is quite a crude and inelegant way, but it may very well work. Quote Link to post Share on other sites
stasundr 0 Posted October 29, 2014 Share Posted October 29, 2014 roadrunner84, thank you! Now the idea is clear. Could you please give me an idea how to implement write to sd card in this way? Is it possible to do it in Energia or something more sophisticated is required? Quote Link to post Share on other sites
roadrunner84 466 Posted October 29, 2014 Share Posted October 29, 2014 roadrunner84, thank you! Now the idea is clear. Could you please give me an idea how to implement write to sd card in this way? Is it possible to do it in Energia or something more sophisticated is required? Everything is possible in Energia, it's just C++ with some framework. I cannot help you to fix your issue, you'll have to rewrite large portions of the SD library to get thing working this way. Quote Link to post Share on other sites
stasundr 0 Posted October 30, 2014 Share Posted October 30, 2014 Everything is possible in Energia, it's just C++ with some framework. I cannot help you to fix your issue, you'll have to rewrite large portions of the SD library to get thing working this way. Thank you for your help. Considering the fact that I'm just a newbie, it's impossible for me to rewrite large portions of the SD library. So it looks more reasonable to use a bluetooth module instead of SD card and just send temp. sensor data right to the server. Quote Link to post Share on other sites
LiviuM 43 Posted October 31, 2014 Share Posted October 31, 2014 The only file on sdcard is "SD card test.txt", PFatFS uses the 8.3 naming convention.That means, a longer name will be "truncated" to 8 characters. In the case of a file with a name as you used ("SD card test.txt"), PFatFS shows me it as "SDCARD~1.TXT". Maybe an ideea will be to start keeping just the directory listing part from the test sketch, to see if you have communication and just the name is wrong, or you don't have communication at all. /*-----------------------------------------------------------------------*/ /* Program Main */ /*-----------------------------------------------------------------------*/ void loop() { Serial.println(); Serial.println("Open root directory."); delay(100); rc = FatFs.opendir(&dir, ""); if (rc) die(rc); Serial.println(); Serial.println("Directory listing..."); delay(100); for (; { rc = FatFs.readdir(&dir, &fno); /* Read a directory item */ if (rc || !fno.fname[0]) break; /* Error or end of dir */ if (fno.fattrib & AM_DIR) {Serial.print("<dir>\t"); Serial.println(fno.fname);delay(100);} else {Serial.print(fno.fsize);Serial.print("\t"); Serial.println(fno.fname);delay(100);} } if (rc) die(rc); Serial.println(); Serial.print("Test completed."); //for (; ; } PS I'm using a tivac board. stasundr 1 Quote Link to post Share on other sites
stasundr 0 Posted October 31, 2014 Share Posted October 31, 2014 PFatFS uses the 8.3 naming convention.That means, a longer name will be "truncated" to 8 characters. In the case of a file with a name as you used ("SD card test.txt"), PFatFS shows me it as "SDCARD~1.TXT". Maybe an ideea will be to start keeping just the directory listing part from the test sketch, to see if you have communication and just the name is wrong, or you don't have communication at all. /*-----------------------------------------------------------------------*/ /* Program Main */ /*-----------------------------------------------------------------------*/ void loop() { Serial.println(); Serial.println("Open root directory."); delay(100); rc = FatFs.opendir(&dir, ""); if (rc) die(rc); Serial.println(); Serial.println("Directory listing..."); delay(100); for (; { rc = FatFs.readdir(&dir, &fno); /* Read a directory item */ if (rc || !fno.fname[0]) break; /* Error or end of dir */ if (fno.fattrib & AM_DIR) {Serial.print("<dir>\t"); Serial.println(fno.fname);delay(100);} else {Serial.print(fno.fsize);Serial.print("\t"); Serial.println(fno.fname);delay(100);} } if (rc) die(rc); Serial.println(); Serial.print("Test completed."); //for (; ; } PS I'm using a tivac board. omg! Thank you so much! Your code really works Open root directory. Directory listing... 4096 ~1.TRA <dir> TRASHE~1 <dir> FSEVEN~1 37 SDCARD~1.TXT 4096 _SDCAR~1.TXT Test completed. Now I'm gonna try to write on SD card Quote Link to post Share on other sites
stasundr 0 Posted October 31, 2014 Share Posted October 31, 2014 It is possible to write into my file ("SDCARD~1.TXT"), but by some reason I can't exceed initial size (37 bytes). Could someone please explain me the reason why? Is it related with msp430g2553 ram size? Quote Link to post Share on other sites
LiviuM 43 Posted October 31, 2014 Share Posted October 31, 2014 There are some limitation in using the write function. Calin has listed them in the post 4. Impossibility to change the size of the file is one of them. stasundr 1 Quote Link to post Share on other sites
stasundr 0 Posted November 1, 2014 Share Posted November 1, 2014 There are some limitation in using the write function. Calin has listed them in the post 4. Impossibility to change the size of the file is one of them. Hopefully, it is possible to live with. Could you evaluate my plan? 1) Create two 2mb "empty" files on SD card (fileA and fileB). 2) Write log data to fileA and remember how much space already have taken. 3) When fileA is almost full with log data, start writing to fileB 4) When fileB is almost full with log data, start writing to fileA and so on. Considering the fact that 1 line of log less then 32 bytes (YYYY.MM.DD HH.MM Temp) and mcu check temperature once in a minute, 2mb file can store data for one month and a half. File size could be increased, 2mb files are just for test purposes. Quote Link to post Share on other sites
LiviuM 43 Posted November 1, 2014 Share Posted November 1, 2014 Hello, Unfortunattely I can't help you any furter. All I've done with this library was to connect a card to my Launchpad and make some communication tests. But in my oppinion your plan has big chances to work. Success, Liviu Quote Link to post Share on other sites
Rei Vilo 695 Posted December 9, 2014 Share Posted December 9, 2014 To select another SPI port on the LM4F120 or TM4C123, have a look at the Sd2Card::init function. uint8_t Sd2Card::init(uint8_t chipSelectPin, uint8_t sckRateID, int8_t SPI_Port, int8_t cardDetectionPin, int8_t level) #if defined(__LM4F120H5QR__) || defined(__TM4C1230C3PM__) || defined(__TM4C123GH6PM__) || defined(__TM4C129XNCZAD__) || defined(__TM4C1294NCPDT__) // LM4F and TM4C specific if (SPI_Port >= 0) { SPI_for_SD.setModule(SPI_Port); } #endif Quote Link to post Share on other sites
AlexH 0 Posted December 10, 2014 Share Posted December 10, 2014 Hi all, I have a question that's directed a little more towards the hardware side of interfacing my TM4C123G launchpad with my SD card module using this library. If anyone has any thoughts or ideas, please let me know here: http://forum.stellarisiti.com/topic/2205-help-with-sd-card-module-on-tm4c123gxl/ Thanks so much. Quote Link to post Share on other sites
emihackr97 0 Posted February 12, 2015 Share Posted February 12, 2015 Hello, I'm also getting the messgage Failed with rc=6, please someone help us out! 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.