I want to read data present in a '.txt' file into a float array in the MSP430. I have installed the FatFs library in my project and have also looked at some example codes written for performing the basic tasks of opening, reading and writing the files using this library. I have a doubt regarding the implementation of these examples on my MSP430. Do I need to store the FatFs on an SD Card or do I load it in my project and load an SD Card that contains the files I need to read from? Also, another part that I am confused about is the use of fmount() and the concept of drives used in the FatFs. How can the different drives be created or considered on MSP430 if at all they are needed. I have created a preliminary code sample of what I want to achieve on the MSP430 as follows:
#include <stdio.h> #include <msp430.h> #include <stdlib.h> #include <string.h> #include "DSPLib.h" #include "ff.h" FATFS FatFs; int main() { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer FIL fil; char line[100]; FRESULT fr; int i; float bias3[2], num; fr = f_open(&fil, "bias3.txt", FA_READ); if (fr) return (int)fr; while (f_gets(line, sizeof line, &fil)) { printf(line); } f_close(&fil); return 0; }
I tried to adapt the code that I found in the example such that I can read a simple txt file containing two float values into my array. This code tries to read the data line by line. The data file is structured as follows:
-0.08071705 0.08071705
While currently my file is in the project folder, I know that I need to move it onto either an SD card or some location where the file system can find it. Do I need to use the SDCardLib available in the MSP430 as well or is there a different way of accomplishing the same? I am trying to look for some examples but so far have only come up with very basic answers from which I couldn't extract much information. Any kind of leads or ideas would be very helpful. Please let me know if any more information is required as well. Thank you.