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.

Saving .txt file to ROM



Hi,

I am new with to the MSP430 (F2274) and to IAR Embedded workbench.  I have spent all day unsuccesfully searching and reading to try and find the answer to my query, so was hoping someone could help me.

Basically I have a text file containing a series of numbers, and wish to store them on to the MSP430, ready for processing.  These numbers are fixed and don't need to be altered during the processing, but I am having difficulty in finding out how to simply save the text file to memory.

In the MSP430 Compiler reference guide I see information about using __data16 and __word16 in the data storage chapter but am not sure how to use this for my situation inputting a textfile into ROM.

Does anyone have any ideas on how to do this?  Any help would be much appreciated.

 

 

  • if these values are comma separated and valid numbers (in terms of C programming), you can try the following:

    in your C code, add the following:

    unsigned int data[]={
    #include "data.txt"
    };

    this generates an array 'data' that contains all the values from data.txt.
    To make this work, the values in data.txt must be all positive integers, separated by comma and no comma after the last.
    If the values are just 0..255, you can use an unsigned char array, and if they are signed, omit the 'unsigned'.

    Since the data is constant, you migh twant to place it in flash instead of usinng initialized ram space. Then add teh 'static const' keywords to the array declaration. The linker should then put the data into flash and access it from there.

  • Thanks very much!

**Attention** This is a public forum