Tool News
 
 
 

Tool News

Products Info
Downloads
Tools FAQs
MAEC TOOL NEWS: MAECT-M3T-NC308WA-021216D

Notes on C Compiler
M3T-NC308WA V.5.00 Release 1

Please take note of the following problems in using C compiler (with an assembler and integrated development environment) M3T-NC308WA V.5.00 Release 1 for the M32C/80, M16C/80, and M16C/70 series MCUs:
  • On locating variables qualified by the type qualifiers "near" and "far"
  • On renaming a rom or data section by the #pragma SECTION directive command


  1. Problem on Locating Variables Qualified by the Type Qualifiers "near" and "far"
    1.1 Description
    Even if variables are defined with qualification by the type qualifiers "near" (or "_near") and "far" (or "_far"), these qualifiers may have no effect on determining the sections where the variables are located; that is, the variables will be located in the same sections as they were not qualified.
    In addition, when the compile options "-fFRAM (-ffar_RAM)", "-fNROM (-fnear_ROM)", and so on are used at the same time, type qualifiers normally have precedence over them in determining variable's locations.
    However, variables qualified as "near" and "far" may be located as if they were not qualified since the type qualifiers have lost their function and the compile options take precedence in determining the locations of the type-qualified variables.

    Note that the addressing modes of the codes for accessing variables are correctly created according to type qualifiers, though variables are located in the wrong sections.

    1.2 Conditions
    This problem occurs if the following three conditions are satisfied:
    (1) A variable is declared outside of a function, or a variable is declared to be static inside a function.
    (2) In the declaration of the variable in (1), a type qualifier "near", "far", "_near" or "_far" is used.
    (3) The type qualifier in (2) specifies a section different from the default or, if the default section has been changed by using any option, a section different from the one after the change has been made.

    1.3 Example
    Source file: "file_a.c"
    ------------------------------------------------------------------
       int             a;
       int near        b;
       int far         c;
       int             i = 0;
       int near        j = 1;
       int far         k = 2;
       const int       x = 3;
       const int near  y = 4;
       const int far   z = 5;
    ------------------------------------------------------------------
    When the above source file is compiled without the "-fFRAM" and "-fNROM" options, the variables qualified as "near" and "far" are located as shown in the list below.
    Here, the sections where variables meeting the conditions in 1.2 above are located are shown in the Actual column.
    Declarations of VariablesSpecifiedActualComment
    /* With no initial values;
               default is "near" */
         int       a;
         int near  b;
         int far   c;

    bss_NE
    bss_NE
    bss_FE

    bss_NE
    bss_NE
    bss_NE



    Wrong
    /* With initial values;
               default is "near" */
         int       i = 0;
         int near  j = 1;
         int far   k = 2;

    data_NE
    data_NE
    data_FE

    data_NE
    data_NE
    data_NE



    Wrong
    /* const; default is "far" */
         const int       x = 3;
         const int near  y = 4;
         const int far   z = 5;

    rom_FE
    rom_NE
    rom_FE

    rom_FE
    rom_FE
    rom_FE


    Wrong

    1.4 Workaround
    This problem can be circumvented by following the procedure shown below.
    Step 1.Provide a new source file and define the variables that will not be located in the specified sections in it.
    Step 2.Compile the new file in Step 1 with the "-fFRAM" and "-fNROM" options being selected to locate the variables in the specified sections.
    Step 3.Modify the original file by adding "extern" to the lines defining the variables not located correctly in this source file and by referencing the variables defined in the new source file in Step 1. Then compile it without the "-fFRAM" and "-fNROM" options.
    Step 4.Link the file created by the compilation in Step 2 with the original file modified and compiled in Step 3.

    [Example of circumventing the example in 1.3:]
    Step 1. Define the variables c, k, and y in the new "file_b.c" file.
    "file_b.c"
    ------------------------------------------------------------------
    int far         c;
    int far         k = 2;
    const int near  y = 4;
    ------------------------------------------------------------------
    Step 2. Compile "file_b.c" using the "-fFRAM" and "-fNROM" options.
    ------------------------------------------------------------------
    >nc308 -c -fFRAM -fFROM file_b.c
    ------------------------------------------------------------------
    Step 3. Modify the original file "file_a.c" as shown below. Be sure to compile this file without the "-fFRAM" and "-fNROM" options.
    "file_a.c"
    ------------------------------------------------------------------
    int             a;
    int near        b;
    extern int far  c;        /*Add extern*/
    int             i = 0;
    int near        j = 1;
    extern int far  k;        /*Add extern;delete the initial value*/
    const int       x = 3;
    extern const int near  y; /*Add extern;delete the initial value*/
    const int far   z = 5;
    ------------------------------------------------------------------
    Step 4. Link the file "file_b.r30" created in Step 2 with the file "file_a.r30" created in Step 3.
    ------------------------------------------------------------------
    >nc308 file_a.r30 file_b.r30
    ------------------------------------------------------------------
    1.5 Schedule of Fixing the Problem
    We plan to fix this problem in our next release of the product.


    Notes on C Compiler M3T-NC308WA V.5.00 Release 1
    MAECT-M3T-NC308WA-021216D

  2. Problem on Renaming a rom or data Section by the #pragma SECTION Directive Command
    2.1 Description
    When more than one #pragma SECTION Directive is used for rom or data sections in a single source file, compilation may be unsuccessfully terminated.

    2.2 Examples
    (1) The case where System Error occurs
    file_c.c
    ------------------------------------------------------------
       const int   a = 0;
       #pragma SECTION rom rom1
       const int   b = 1;
       #pragma SECTION rom rom2
       const int   c = 2;
       #pragma SECTION rom rom3
       const int   d = 3;
       #pragma SECTION rom rom4
       const int   e = 4;
       #pragma SECTION rom rom5
       const int   f = 5;
    ------------------------------------------------------------
    (2) The case where core dump occurs
    file_d.c
    ------------------------------------------------------------
       int i = 0;
       #pragma SECTION data data1
       #pragma SECTION data data2
       #pragma SECTION data data3
       #pragma SECTION data data4
       #pragma SECTION data data5
       #pragma SECTION data data6
       #pragma SECTION data data7
       #pragma SECTION data data8
       #pragma SECTION data data9
       #pragma SECTION data data10
       int j = 2;
    ------------------------------------------------------------
    2.3 Workaround
    When a rom or data section is split into two or more sections, also split the source file in which variables are defined into those corresponding to the split sections.
    If unnecessary lines describing the #pragma SECTION directives exist, change them to comment lines.
    [Example of circumventing the examples in 2.2:]
    (1) Define the sections rom1 through rom5 that have been defined in "file_c.c" now in their respective files along with the variables involved.
    (a) Reference the variables b, c, d, e, and f externally:
    file_c.c
    --------------------------------------------------------
       const int   a = 0;
       extern const int    b, c, d, e, f;
    --------------------------------------------------------
    (b) Define the rom1 section and its variable b in file_c_1.c:
    file_c_1.c
    --------------------------------------------------------
       #pragma SECTION rom rom1
       const int   b = 1;
    --------------------------------------------------------
    Define rom2 through rom5 with their variables the same way as rom1.
    (2) Change the unnecessary lines describing the #pragma SECTION directives in "file_d.c" to comment lines.
    ------------------------------------------------------------
       int i = 0;
       /*#pragma SECTION data data1*/
       /*#pragma SECTION data data2*/
       /*#pragma SECTION data data3*/
       /*#pragma SECTION data data4*/
       /*#pragma SECTION data data5*/
       /*#pragma SECTION data data6*/
       /*#pragma SECTION data data7*/
       /*#pragma SECTION data data8*/
       /*#pragma SECTION data data9*/
       #pragma SECTION data data10
       int j = 2;
    ------------------------------------------------------------
    2.4 Schedule of Fixing the Problem
    We plan to fix this problem in our next release of the product.




© 2008. Renesas Technology Corp., All rights reserved. Privacy | Legal