Olimex Support Forum

Microcontrollers => MSP430 => Topic started by: phlebire on August 02, 2013, 05:01:58 PM

Title: MSP430-5510STK collect and store data in a text file + SD card
Post by: phlebire on August 02, 2013, 05:01:58 PM
Hello,
I am currently working on a project using the OLIMEX MSP430-5510STK. I have chosen this particular board because it seems it can provide an external .txt file when connected by USB to the computer.
My board will regularly take analog readings from a PCB prototype and what I need is to understand how to code the board (I am using C code) in order to store this data and transform it into this .txt file. I use IAR EW to get the .txt file that I insert through USB to the board using the MSP 430 USB Firmware Upgrade Example.
Indeed I can't find in the examples (MSP-5510STK_Full_Example) provided neither this forum the part where the .txt file (as an external hard drive) is created. The idea is to dump this .txt regularly to my computer to be able to see how the test is going on.
In addition to this, it would be perfect if I could store the entire testing period data in a SD-card. It seems I can connect a SD-card to the board and if I could store the data in parallel to the USB .txt file it would be a blessing.
Any help would be very much appreciated,
Regards,
Clément
Title: Re: MSP430-5510STK collect and store data in a text file + SD card
Post by: phlebire on August 13, 2013, 10:33:32 AM
Hello again,

just to say that I am still trying to look for this solution so any information will still be helpful :-)
Title: Re: MSP430-5510STK collect and store data in a text file + SD card
Post by: phlebire on August 14, 2013, 11:22:51 AM
OK well maybe some will need this information because they are like me rather newbie in FAT programming so I will post my solution to this. I have used the "MSP-5510STK_Example" --> Full example. Keep that code and add:


// variables
FATFS fatfs;
FIL fp;
UINT bw;
UINT result;
char success = 0;


// code segment to be inserted in the main loop
      if (!success) {
        f_mount(0, &fatfs);
        memset(&fp, 0, sizeof(fp));
        char str[] = "Hello world!\n";
        result = f_open(&fp, "test.txt", FA_WRITE);
        if (result == FR_OK) {
          result = f_write(&fp, str, strlen(str), &bw);
        }
        result = f_close(&fp);
        success = (result == FR_OK);
      }


Just one thing doesn't work here: the "\n" seems not to work in .txt files. But it is a minor problem.
Title: Re: MSP430-5510STK collect and store data in a text file + SD card
Post by: brayden_520 on February 28, 2016, 12:23:22 AM
you can modify that "Hello World!\r\n"