Jump to content
43oh

[Energia Library] Stellaris Launchpad FatFs Energia library


Recommended Posts

This is a port to Energia of the Arduino library from this page: http://pressplay.pbworks.com/w/page/25687375/FatFs

 

The diskio.c driver is from Stellarisware example for lm4f232 with some changes:

- use digitalWrite for CS control

- use delays instead of timers for timeouts

 

The card must be connected to SSI0 (hardcoded in driver) but CS signal is defined in sketch and can be any pin.

 

I checked the FileWriteToSerial example and it is working with uSD and uSDHC cards (2GB and 8GB). I connected the uSD cards with and adapter to SD using the first method presented here: http://www.43oh.com/2011/02/five-cheap-breadboard-prototyping-tips-and-tricks-list-2/

 

Also, I'm not a good programmer (I had first hands-on experience with C when I discovered Energia) so some parts of the code might be optimised further for Stellaris.

 

Extract the archive in Energia\hardware\lm4f\libraries\ and enjoy!

 

[uPDATE] See post #7 http://forum.stellarisiti.com/topic/442-energia-library-stellaris-launchpad-fatfs-energia-library/#entry2553

[DOWNLOAD LINK] http://forum.stellarisiti.com/index.php?app=core&module=attach&section=attach&attach_id=335

 

The file attached to this post is the first version. For the updated library please use the link above.

FatFs_03.zip

Link to post
Share on other sites
  • 4 weeks later...
  • Replies 50
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

This is a port to Energia of the Arduino library from this page: http://pressplay.pbworks.com/w/page/25687375/FatFs   The diskio.c driver is from Stellarisware example for lm4f232 with some changes:

I am afraid this wrapper doesn't have mentioned functionality. But normal FatFs library can. I use it with Energia without any problems. I use diskio.c from one of the StellarisWare examples, modified

@calinp - can You show a simplest example for log string data to file? (If file doesn't exist then create it, and append new data at the end - nothing else)   tnx!

Posted Images

  • 2 weeks later...

G'day Cain,

Got the lib to work at last. The problem was not with the lib, but with using an arduino shield, that only takes a micro SD's.

After getting a sparkfun SD and wiring up the signals, all worked great.

I think I spent more time on decoding the SPI signals (mainly MISO) on my Cro  then anything else.

Makes one want to spend a few $$'s on a SPI to Hex display.

Anyway, will get on and have a good play with the lib's other functions.

Tks for your help once again.

Grant

Link to post
Share on other sites

Hi Grant,

Try to add a pull-up resitor of 1K to MISO pin. The original driver enables the weak pull-up for MISO, but in the the Energia SPI lib it is not enabled. You can also try to set the MISO pin with pinMode(MISO, INPUT_PULLUP) before SPI.begin.

 

Regards,

Calin

Link to post
Share on other sites

G'Day Calin,

Yup will give try out your suggestions, when I get back into town.

One thing I have added is a 1000MFD capacitor across the 3v3 supply at the SD card holder.

I found that each time I plugged in a SD card it would reset the processor. Also noted that a 470 MDF was not large enough.

 

Grant

Link to post
Share on other sites

Update to support the SPI driver and different SSI modules:

- FatFs.begin(cs_pin) -> defaults to SSI2 and maximum SPI clock

- FatFs.begin(cs_pin, clock_divider) -> SSI2 and SPI clock is divided by clock_divider.

- FatFs.begin(cs_pin, clock_divider, module) -> SPI clock is divided by clock_divider, new SSI module selection

- inherited print functions ( can be enabled in ffconf.h )

 

Pin 9 is used as CS inside the SPI library and it is toggled at each byte transferred so it can't be used by FatFs.

I made some tests with CS control disabled inside the SPI lib and the transfer speed increases by ~50%.

 

If the card can't be initialized, a possible solution is a 1K pull-up resitor from MISO to VDD.

 

Because this library doesn't use low level access to hardware it shoul be compatible with further boards supportded by Energia (with enough RAM).

 

Calin

 

[EDIT]  corrected the speed test example

FatFs_SpeedTest.txt

FatFs05.zip

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

Hello,

I will do some check on this.

Try to use the printf function for writing in files (needs to be enabled in ffconf.h, _USE_STRFUNC 1). Also disable the print support ( _USE_PRINT 0)

I was trying this but always end with FR_NOT_ENABLED error .. and I must say that i do not know what this error mean... maybe I am doing something wrong...

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