Jump to content
43oh

PetiteFS FATfs SDCard USCI code


Recommended Posts

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 ?

Link to post
Share on other sites
  • 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

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
>
 
Link to post
Share on other sites

 

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!

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

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.

Link to post
Share on other sites

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

Link to post
Share on other sites

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 :)

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

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!

Link to post
Share on other sites

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.

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

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

Link to post
Share on other sites

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.

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