Jump to content
bluehash

PetiteFS FATfs SDCard USCI code

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

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

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.

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

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

×