MSP430-5510STK collect and store data in a text file + SD card

Started by phlebire, August 02, 2013, 05:01:58 PM

Previous topic - Next topic

phlebire

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

phlebire

Hello again,

just to say that I am still trying to look for this solution so any information will still be helpful :-)

phlebire

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.