mac1234 0 Posted September 17, 2013 Share Posted September 17, 2013 Newbie question. Just got the SD card booster pack last week for launchpad 2553 (version 1.5) board. I tried to run the code version 0.3 from wiki page with 1 GB microSD card. I can read successfully from the card but I couldn't get anything to write to the write.txt file. All terminal messages for 'fw' command looks right - I get the "Finalizing the file write" message but nothing gets written to the file. Any help ? Quote Link to post Share on other sites
bluehash 1,581 Posted September 17, 2013 Author Share Posted September 17, 2013 Do you get any return codes, when you step through the code? Quote Link to post Share on other sites
mac1234 0 Posted September 18, 2013 Share Posted September 18, 2013 Bluehash, This is what I get on the terminal: PFF test monitor commands are: di,fi,fo,fd,fl,ft,fw > di Disk Initialize... rc=0 > fi rc=0 FR_OK > fl command is run here 0 WRITE.TXT 1 item(s) > fw Trying to open an existing file for writing (write.txt)... Writing 100 lines of text data ................................................ Finalizing the file write. > fl is run here 0 WRITE.TXT 1 item(s) > fo write.txt rc=0 FR_OK > fd command is run here > Quote Link to post Share on other sites
bluehash 1,581 Posted September 18, 2013 Author Share Posted September 18, 2013 Looks ok. In your code, when you open the file.. do you make sure that the return code was 0? Quote Link to post Share on other sites
mac1234 0 Posted September 19, 2013 Share Posted September 19, 2013 I used the code from wiki page as such without any changes and it does check for res == FR_OK before writing to the file I think. Do I need anything to do hardware wise ? I used the board out of the box. Quote Link to post Share on other sites
CsCrazy 5 Posted September 25, 2013 Share Posted September 25, 2013 Bluehash, This is what I get on the terminal: PFF test monitor commands are: di,fi,fo,fd,fl,ft,fw > di Disk Initialize... rc=0 > fi rc=0 FR_OK > fl command is run here 0 WRITE.TXT 1 item(s) > fw Trying to open an existing file for writing (write.txt)... Writing 100 lines of text data ................................................ Finalizing the file write. > fl is run here 0 WRITE.TXT 1 item(s) > fo write.txt rc=0 FR_OK > fd command is run here > Hi! I have exactly the same problem here! Using PetiteFS version 1.02 though but still.. I can read from the card (at least i think so because the fl (directory listing) works), but cannot write. I haven't changed much of the code, only the chip-select pin P2.0 --> P1.4... I have formatted the card as FAT and used default allocation size. Windows shows 0 bytes too after I tried to fw (write 100 lines, opened the file before writing). Any help is appreciated! Quote Link to post Share on other sites
CsCrazy 5 Posted October 5, 2013 Share Posted October 5, 2013 I helped myself here and got the write function working. You have to make an empty file, or use any kind of file actually that's large enough so that writed bytes are actually written in the SD card. This is because of the limitations with the PetitFS library. The PetitFS can't make files any bigger, so there must be a "dummy" -file in the directory or in the cards root for writes to work. This is actually documented in the web site: http://elm-chan.org/fsw/ff/pf/write.html So maybe next time i'll read the f***ing manual instead of crying for help :DD So summa summarum, here's the steps i got it working: 1) Format SD-card to FAT 2) Create file which has some data in it. File can be txt-file for example. How you create the file is your proplem, but there are tools available. If requested, i can send my program which i wrote to make any size file i want, you have to install it though because it's written in C# and uses .NET. 3) Plug the card in the MSP430 (i know you can't really "plug" it in there but you know what i mean) 4) Write functions will now work for the created file 5) Be happy, take a cup of coffee or a beer. I hope this helps someone. bluehash 1 Quote Link to post Share on other sites
Rickta59 589 Posted October 8, 2013 Share Posted October 8, 2013 OK, yet another version of the code. What is special about it? o Compiles with both msp430-gcc and CCS 5.5 ( at least that is what i tried ) o Doesn't use any interrupts or timers o Uses Hardware USCI UART instead of softserial o Changed back to the slightly modified tinyprintf to make is smaller and happy on msp430-gcc o Moved data structures into the global space to make it easier to see how the different compile options affect the ram usage. o Removed all warning (aside from the CCS power saver whining stuff ) o Input routine echos as you type, handles backspace editing, and limits input to buffer size o fd command (hex dump) can be repeated by pressing enter after the first time. o More explicit help in serial console. o Uses P2.0 as CS (chip select active low) o Optional bitbang spi implementation you might try on smaller chips ( I've tried on g2553 not other chips ) -rick [sdcard_monitor.zip - archived CCS project. For msp430-gcc use, just unzip and use instructions in main.c ] sdcard_monitor.zip CsCrazy and bluehash 2 Quote Link to post Share on other sites
CsCrazy 5 Posted October 9, 2013 Share Posted October 9, 2013 Rickta59 this is good I think i'm gonna try this soon as I get home from work. I like that you have modified the code to be smaller and that now HW-UART is used, because that's more efficient way to do things... and in my opinion it's the right way to put data through serial port (well at least on chips which do have USCI). I've noticed that you have changed the CS-line selection more easier. Only one or two (depending on the port being used) changes are needed in SPI.h file, good! (CS_POUT and CS_BIT) But on the bitbanging side, there's no defines how to select pins that the user wants. Anyways if user isn't a beginner, he/she is able to change the port bits easily, not a biggie. But this could be made a bit more easier too, as in HW-SPI. Nevertheless, great work, much appreciated Quote Link to post Share on other sites
bluehash 1,581 Posted October 17, 2013 Author Share Posted October 17, 2013 Thanks for maintaining the code, @@Rickta59 Quote Link to post Share on other sites
steelgone 0 Posted November 30, 2013 Share Posted November 30, 2013 I'm currently working on implementing the sd card code to use with the breakout board I got. All of the examples I have seen are using the MSP430 of some variation. I am trying to use this code for application with an LM4F* launchpad or TM4C123 launchpad. Can anybody lead me in the right direction on what all I need to change in the code for proper interface. Has anybody accomplished this yet? Any help is appreciated! Quote Link to post Share on other sites
bluehash 1,581 Posted November 30, 2013 Author Share Posted November 30, 2013 I'm currently working on implementing the sd card code to use with the breakout board I got. All of the examples I have seen are using the MSP430 of some variation. I am trying to use this code for application with an LM4F* launchpad or TM4C123 launchpad. Can anybody lead me in the right direction on what all I need to change in the code for proper interface. Has anybody accomplished this yet? Any help is appreciated! @@steelgone, welcome to the forum. No one has done it yet. If you are interested in a challenge, start a thread at forum.stellarsiti.com and members will guide you through. steelgone 1 Quote Link to post Share on other sites
steelgone 0 Posted November 30, 2013 Share Posted November 30, 2013 @@steelgone, welcome to the forum. No one has done it yet. If you are interested in a challenge, start a thread at forum.stellarsiti.com and members will guide you through. It's definitely been a challenge so far. Thanks, I followed your advice. Quote Link to post Share on other sites
akshay 0 Posted December 9, 2013 Share Posted December 9, 2013 BlueHash, Thanks for the code. i haven't tried it yet, but i will soon. My project includes audio files to be taken from the sd card and give it to a DAC. Is it possible to play different files based on some condition using this code? For instance if a parameter "a" is passed to the function it plays the file based on the value of "a". Quote Link to post Share on other sites
bluehash 1,581 Posted December 9, 2013 Author Share Posted December 9, 2013 BlueHash, Thanks for the code. i haven't tried it yet, but i will soon. My project includes audio files to be taken from the sd card and give it to a DAC. Is it possible to play different files based on some condition using this code? For instance if a parameter "a" is passed to the function it plays the file based on the value of "a". It can, yes, with modification. You will have to prewrite the files on an SD card on a PC. You can use the existing serial parser to read data from the sd-card into the DAC. 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.