This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CCS/TMS320F28335: Storing .csv/.txt file in F28335

Part Number: TMS320F28335

Tool/software: Code Composer Studio

Hello,

I am working on a project that requires the microcontroller to operate without being connected to the computer. However, part of my code requires that it reads .csv/.txt files in order to receive data tables and the only way I was able to manage this was by adding these files in my debug folder. I need about 20 of these files to be saved (about 15,000 bytes).

I'd be very grateful for your help.

Thank you in advance!

Jose

  • Jose,

    Are you asking how you can store the files in the memory on the F28335?  i.e currently you are reading them from the \Debug folder on your PC but you need to move to reading them from the device itself.

    John

  • Hey John,

    Yes that's exactly what I am trying to do.

  • Jose,

    Ok.  For this I will need to loop in some C2000 experts.

    Regards,

    John

  • Can you give me some more details? Can it be as simple as doing some preprocessing on your csv/.txt files on your computer to turn them into .c files containing const arrays of the data that can be compiled into your application?

    Whitney

  • Whitney Dewey said:

    Can it be as simple as doing some preprocessing on your csv/.txt files on your computer to turn them into .c files containing const arrays of the data that can be compiled into your application?

    Yes, I believe so. What I am currently doing is reading the files and converting the data into 2 arrays.

  • Okay, I think that's going to be your easiest option instead of trying to deal with file IO on the device. Write a script that converts your data files to an array format that can be compiled into your project. You could even add the script to your pre-build steps in your CCS project properties if you want to regenerate them every time you rebuild your project.

    Whitney

  • Thank you for your response, Whitney.

    Whitney Dewey said:

    Write a script that converts your data files to an array format that can be compiled into your project. You could even add the script to your pre-build steps in your CCS project properties if you want to regenerate them every time you rebuild your project.

    How do you create a script and add it to the pre-build steps?

    Can you point me in the right direction, please.

    Thank you so much in advance!

    -Jose

  • Pre-build steps can be found in the project properties. With "Build" selected in the left panel, you should see a tab  that says "Steps" on the right. There you enter commands that can be run as pre- or post-build steps--like calling another application.

    As for writing the script--do you think you would be able to write an application that runs on your computer to take input from a csv/txt file, parse it, and output a new file in the format of a .c containing an array? It'd be the kind of thing that would be pretty quick to do in Python or Perl if you have any experience with those but you could use whatever language you're comfortable with.

    Whitney

  • Yes, I know how to take input from a csv/txt file and parse it, however, I am unsure how to ouput a new file in the format of a .c containing an array.

    Also, with this new file, will I be able to access it directly or would I have to include the file in one of my files?

    Jose

  • Just print the new file like you would type up a .c file containing an array:

    const uint16_t exampleData1[750] = {
        your data,
        your data,
        etc...
    };

    Add it to your project with the rest of your .c files, so it gets compiled. Somewhere in your code you would extern "exampleData1" so you'll be able to refer to it.

    Whitney

  • Oh okay, thank you so much!

  • Thank you for your help!

    I was able to write the script as you suggested, however, when I build the project, it does not update the c file. In the pre-build steps, I inserted this:

    python ${PHOTOVOLT_LOC}\scripts\import_data.py  %arg1%
    

    I know that it does run the program because I added a GUI feature to select the files, and it shows up. I tried running the program by itself, and it works fine.

    Any suggestions?

    - Jose

  • And that command works fine when you run it from the command line instead of the pre-build steps? Are you seeing any messages in the build console that might hint at what is going wrong?

    Whitney

  • I was able to figure it out, I had to change the directory in my script.

    Thank you so much for all of your help!