bluehash

PetiteFS FATfs SDCard USCI code

144 posts in this topic

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

 

---------------------------------------

First version. It's very untidy as I just got it to work. Works on USCI on the MSP430G2553. Supports Read/Listing. The monitor code does not have write yet. It works on the SDCard Boosterpack.

 

sdcard_boosterPack_Launchpad.PNG

I also used Rickta's serial code to reduce file size. I'll update to the next version once I have time and a clean it up to. Also need to add more features.

Usage in screenshot.
di : disk initialize
fi : mount disk
fl : list files
fo filename: open file name.

msp430_sdcard_fatfs.JPG

Latest Code:
http://www.43oh.com/forum/viewtopic.php?f=10&t=1883&start=20#p18738'>Code Rev 0.2

Member Contributed Code:
Jazz_ys - http://forum.43oh.com/topic/1427-petitefs-fatfs-sdcard-usci-code/page__st__20#entry24449'>Link

SDCARD_PetiteFS_2553_v0.01.zip

SDCARD_PetiteFS_2553_v0.02.zip

xpg, dacoffey, SugarAddict and 12 others like this

Share this post


Link to post
Share on other sites

Thanks bluehash! I couldn't get it to work with my SanDisk 1GB microSD card. However, with a

few small tweaks to spi.c, I got it humming:

 

/* Initialize and enable the SPI module */
void spi_initialize( void )
{
 P2DIR |= BIT0;      // CS Line
 UCB0CTL1 |= UCSWRST;
 //UCB0CTL0 |= UCMSB |  UCMST | UCMODE_0 | UCSYNC;
 UCB0CTL0 = UCCKPL + UCMSB + UCMST + UCMODE_0 + UCSYNC;
 UCB0CTL1 = UCSSEL_2 | UCSWRST;

 UCB0BR0 = 0x02; // 8MHz
 UCB0BR1 = 0x00;

 P1SEL  |= BIT5 | BIT6 | BIT7; // P1.5, P1.6, P1.7 option select
 P1SEL2 |= BIT5 | BIT6 | BIT7;

 UCB0CTL1 &= ~UCSWRST;

 P2OUT |= BIT0;       // CS high

}

 

-rick

Share this post


Link to post
Share on other sites
Awesome.. is this for the 2553 series?

 

I was actually using an msp430g2533. I think is the same as a 2553 without a comparator.

 

-rick

Share this post


Link to post
Share on other sites

Not much I'm afraid. Use the 2553 if you can or sample it from TI.

 

If you want it to work on the 2452 you will have to change the base driver to support USI. 2452 does not have USCI.

Share this post


Link to post
Share on other sites

I have not used this code as of now, but could you tell me how much flash and ram it uses?

might be interesting for projects involving audio or whatever anyone can come up with.

Share this post


Link to post
Share on other sites
I have not used this code as of now, but could you tell me how much flash and ram it uses?

might be interesting for projects involving audio or whatever anyone can come up with.

 

On the MSP430G2553, no write support yet

MSP430: Program loaded. Code Size - Text: 3410 bytes  Data: 220 bytes

Share this post


Link to post
Share on other sites

Awesome way to beef up the MSP. I have a couple of questions:

 

what kinds of commands can be used to utilize this as a data logger?

 

can you shoot sensor values through the ADC to an open file on the SD?

 

I assume you can access the SD through interrupts?

 

please pardon my ignorance of this......

 

Thanks

Share this post


Link to post
Share on other sites
what kinds of commands can be used to utilize this as a data logger?

- Open/Read/Write File

- Delete file

- Seek file

 

can you shoot sensor values through the ADC to an open file on the SD?

Yes

 

I assume you can access the SD through interrupts?

Should be.

 

please pardon my ignorance of this......

Pardoned. Now go party.

kenemon likes this

Share this post


Link to post
Share on other sites

Bluehash,

 

I am able to run your code on MSP430G2253 with 512MB FAT16 Transcend Micro-SDCard on Launchpad.

 

I had following niggling issues :

* Disconnect J5 jumpers (I have to carefully watch your picture)

* Configure Termite to send CR-LF after every entry

 

* Add a change in main.c:get_line to make the for-loop to exit when it recieves '\n' also. Here is my change (in bold-underlined line):

 

static void get_line(char *buff, BYTE len){

...

if (c == '\r' || c == '\n') break;

...

}

 

So next trial would be for writing :)

 

Regards

 

mahadevan

Share this post


Link to post
Share on other sites

Bluehash,

 

Your FAT-FS code uses SW-Serial-Port for Rs232 communication.

 

As MSP430G2553 contains serial port, why you have not used HW-Serial-Port-Communication(apart from the reason that being portable for other MSP430 MCUs where no HW serial ports are available)?

 

Thanks & regards

 

mahadevan

Share this post


Link to post
Share on other sites
As MSP430G2553 contains serial port, why you have not used HW-Serial-Port-Communication(apart from the reason that being portable for other MSP430 MCUs where no HW serial ports are available)?

 

1. For the above reason mainly.

2. Software UART code was already made by Rickta. I did not want to spend time on setting up the serial port and buffers.

Share this post


Link to post
Share on other sites

Thanks Bluehash.

Now I have a question of using concurrently the HW serial port on MSP2553 (along with Software Serial port):

* One for talking to PC

* Other for integrating to other MCU/Serial-Device (like GPS receiver)

 

It seems that ports used for RX/TX are linked to PC via USB-driver (P1.1 TXD, P1.2 RXD). Software_Serial uses same ports.

Is it possible to remap/change these ports, so that I can have two serial ports (one with PC and other with MCU) simultaneously?

 

regards

 

mahadevan

Share this post


Link to post
Share on other sites

Sorry for not fully understanding this,

What types of SD cards can this be used with? Can it be used with any SD card? Also, for file types on the PC, say I want to store a data string of integers that would correspond to music that could be sent to a DAC, what type of windows file type would I use?

Share this post


Link to post
Share on other sites

I downloaded this code and uploaded it to my MSP430G2553. The program loads fine but whenever I try to use the termite console that you used I can't elicit a response from the board. I enter the same commands you entered in the terminal and nothing happens. The terminal says the board is connected and I can't find any serious issues. I am currently using termite version 2.9. Can you think of any issues that would prevent communication from the boar to the terminal?

Share this post


Link to post
Share on other sites

- What's your Baud Rate?

- Are your RX/TX jumpers on the LP jumpered?

- Make sure termits sends a CRLF when you press enter. The board should respond with >

 

I have the boards ready for shipment if anyone wants it. I've sent a board to Rickta59 to get the "sdcard write" to work. If anyone is interested in the boards, let me know. Price is $8/board assembled.

Share this post


Link to post
Share on other sites

Thank you very much. I managed to get the device up and running.

 

I was looking to modify this code to allow me to write data to the sd card and store it there until I decide to retrieve it without using the console at all. I would like to write a program that can write data from the sd card to a specific address in the card's memory until I decide to retrieve it, again using only the board and not the console. I have tried using the example given by TI but I think it has a few bugs, What I'm essentially looking for is a high level function that will allow me to write to and read from the sd card. Can you point me in the right direction in achieving this goal.

Share this post


Link to post
Share on other sites

Currently the code does not support write. I've sent a boosterpack to Ricta and he'll be working on it.

 

The only caveat with petiteFatFs is that you have to create a file on a PC. Once created the MSP will be able to write to it.

 

Function will be high level. In fact, you can just pick it up from the command line part of the code.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now