16.16.2. Scenario 2 – Hex Conversion Command File for 16-BIS Code

Scenario 2 shows how to build the hex conversion command file to generate the correct converted file for the application code and data that will reside on a single 16-bit EPROM. The EPROM memory system for this scenario is shown in the following figure. For this scenario, the TMS470 CPU operates with the T control bit set, so the processor executes instructions in 16-BIS mode.

Figure: EPROM Memory System for Scenario 2

../../_images/eprom2_pnu118.png

For this scenario, the application code and data reside on the EPROM: the lower 64K words of EPROM memory are dedicated to application code space and the upper 64K words are dedicated to the data tables. The application code is loaded starting at address 0x0 on the EPROM but maps to the TMS470 CPU at address 0x3000. The data tables are loaded starting at address 0x1000 on the EPROM and map to the TMS470 CPU address 0x20.

The following linker command file contains MEMORY and SECTIONS directives that resolve the addresses needed for the load on EPROM and the TMS470 CPU access.

Example: Linker Command File for Scenario 2

/****************************************************************************/
/* Scenario 2  Link Command                                                 */
/*                                                                          */
/*   Usage: armlnk <obj files...>    -o <out file> -m <map file> lnk16.cmd  */
/*          tiarmclang <src files...> -Wl,-o=out_file,-m=map_file lnk32.cmd */
/*                                                                          */
/*   Description: This file is a sample command file that can be used       */
/*                for linking programs built with the TMS470 C              */
/*                compiler.   Use it as a guideline; you may want to change */
/*                the allocation scheme according to the size of your       */
/*                program and the memory layout of your target system.      */
/*                                                                          */
/*   Notes: (1)   You must specify the directory in which rts16.lib is      */
/*                located.  Either add a "-i<directory>" line to this       */
/*                file, or use the system environment variable C_DIR to     */
/*                specify a search path for libraries.                      */
/*                                                                          */
/*          (2)   If the runtime-support library you are using is not       */
/*                named rts16.lib, be sure to use the correct name here.    */
/****************************************************************************/

-m example2.map

/* SPECIFY THE SYSTEM MEMORY MAP */
MEMORY
{
    I_MEM    : org = 0x00000000   len = 0x00000020  /* INTERRUPTS           */
    D_MEM    : org = 0x00000020   len = 0x00010000  /* DATA MEMORY    (RAM) */
    P_MEM    : org = 0x00010020   len = 0x00100000  /* PROGRAM MEMORY (ROM) */
}

/* SPECIFY THE SECTIONS ALLOCATION INTO MEMORY */
SECTIONS
{
    secA: load = 0x3000
    secB: load = 0x20
}

You must create a hex conversion command file to generate a hex output with the correct addresses and format for the EPROM programmer. The EPROM programmer in this scenario has the following system requirements:

  • Because the EPROM memory width is 16 bits, the memwidth value must be set to 16.

  • Because the physical width of the ROM device is 16 bits, the romwidth value must be set to 16.

  • Intel format must be used.

The EPROM programmer does not require a ROM image, so the addresses in the input hex output file do not need to be contiguous.

Because memwidth and romwidth have the same value, only one output file is generated (the number of output files is determined by the ratio of memwidth to romwidth). The output file is named with the -o option.

A ROMS directive is used in this scenario since the paddr option is used to relocate both secA and secB.

The hex conversion command file for Scenario 2 is shown in the example below. This command file uses the following options to select the requirements of the system:

Option

Description

-i

Create Intel format

-map example2.mxp

Generate example2.mxp as the map file of the conversion

-o example2.hex

Name example2.hex as the output file

-memwidth 8

Set EPROM system memory width to 8

-romwidth 8

Set physical ROM width to 8

Example: Hex Conversion Command File for Scenario 2

/* Hex Conversion Command file for Scenario 2               */
a.out                  /* linked object file, input         */
-I                     /* Intel format                      */

/* The following two options are optional                   */
-map example2.mxp      /* Generate a map of the conversion  */
-o example2.hex        /* Resulting Hex Output file         */

/* Specify EPROM system Memory Width and Physical ROM width */
-memwidth 16           /* EPROM memory system width         */
-romwidth 16           /* Physical width of ROM             */

ROMS
{
    EPROM: origin = 0x0, length = 0x20000
}
SECTIONS
{
    secA: paddr = 0x0
    secB: paddr = 0x1000
}

The following example shows the contents of the resulting map file (example2.mxp).

Example: Contents of Hex Map File example2.mxp

*********************************************************
TMS470 Hex Converter               Version x.xx
**********************************************************
Mon Sep 18 19:34:47 1995

INPUT FILE NAME: <a.out>
OUTPUT FORMAT:   Intel

PHYSICAL MEMORY PARAMETERS
    Default data width:    8
    Default memory width:  16
    Default output width:  16

OUTPUT TRANSLATION MAP
---------------------------------------------------------
00000000..0001ffff  Page=0  ROM Width=16  Memory Width=16 "EPROM"
---------------------------------------------------------
    OUTPUT FILES: example2.hex [b0..b15]

    CONTENTS: 00000000..00000003  Data Width=1  secA
              00001000..00001003  Data Width=1  secB

The following figure shows the contents of the resulting hex output file (example2.hex).

Figure: Contents of Hex Output File example2.hex

../../_images/hex_output2_pnu118.png