SLAU320AJ July 2010 – May 2021
As mentioned previously, the target device's program code must be supplied separately. There are two ways to include the provided example in the project space of the program to be sent to the host. Either include a separate file (for example, Target_Code.s43 (IAR) or Target_Code.asm (CCS)) or replace the C-Array in the Target_Code.h header file. Both alternatives must provide the binary target code and conform to the format expected by the source code.
To build these files from the TI-txt format output from the compiler, an open-source conversion program called SRecord can be downloaded from http://sourceforge.net/projects/srecord/. The SRecord package includes the executable srec_cat.exe.
This executable is a command line application that expects parameters in the following format:
srec_cat.exe Target_Code.txt -ti_txt -Output Target_Code.h -c_array -output_word -c_compressed
or
(IAR) srec_cat.exe Target_Code.txt -ti_txt -Output Target_Code.s43 -asm -output_word -a430
(CCS) srec_cat.exe Target_Code.txt -ti_txt -Output Target_Code.asm -asm -output_word -cl430
Parameter description:
The provided file srec.bat generates all three types of output files (.h, .asm, and .s43) simultaneously. The command line format is: srec Target_Code. In addition to generating the actual target code, SRecord is also used to convert the funclets for flash-/Fram-write/erase which can only be rebuilt using IAR Embedded Workbench. In this case the SRecord is started as a post build process in the corresponding projects to convert the TI-txt code to a format accepted by the source code. TI-txt format can be output by the IAR Linker by setting the required compiler/linker options (see the IAR tool instruction guides for more information or see the funclet projects that were described previously). This can also be done in CCS using the hex430 command line executable.
If the TI-txt source file includes odd segment addresses or an odd number of data bytes, additional byte padding might be required to generate appropriate word-aligned output format. Use
srec_cat.exe with a "--fill 0xFF --within <input> --range-padding 2" filter to fix this problem. The srec.bat automatically filters the output format for appropriate word alignment.
For example,
"srec_cat.exe Target_Code.txt -ti_txt --fill 0xFF --within Target_Code.txt -ti_txt --range-padding 2 -Output Target_Code.h -c_array -output_word -c_compressed".
If using assembly source code that contains the target code, make sure that the array declarations are stored in target_code.h. An example can be seen in the included basic header file.
The SRecord conversion program is open source and has a much larger range of functions. For more information and documentation see http://srecord.sourceforge.net/.
This software was tested to function correctly with version 1.36, but is not necessarily compatible with future versions.
To enable easy porting of the software to other microcontrollers, the provided source code is written in ANSI C. As always, it is recommended that the latest available version of the applicable MSP430 development software be installed before beginning a new project.