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/MSP430F449: Linker error

Part Number: MSP430F449

Tool/software: Code Composer Studio

I have migrated working IAR code to CCS with no assembly errors.  However I have a linker error I can't solve.

I copied the below from the TI CCS blank ASM example.

           .cdecls C,LIST,"msp430.h"   ; Include device header file

;-------------------------------------------------------------------------------

           .def   RESET                        ; Export program entry-point to

                                                           ; make it known to linker.

;-------------------------------------------------------------------------------

           .text                                         ; Assemble into program memory.

 

           .retain                                     ; Override ELF conditional linking

                                                           ; and retain current section.

 

           .retainrefs                               ; And retain any sections that have

                                                           ; references to current section.

;-------------------------------------------------------------------------------

; Stack Pointer definition

;-------------------------------------------------------------------------------

            .global __STACK_END

           .sect   .stack

 

RESET           mov.w   #__STACK_END,SP         ; Initialize stackpointer

 

 I then defined all my variables as illustrated below using the same format below.  My last variable was around 0600h, which is well within the RAM resources.

 garb                .equ      0200h   ;garb indicates start of ram

Below is the build error.  There were no reported assembly errors.  With IAR, I never had to view or change any compile or linker settings, as it automatically set them based on the assembly code and MSP part.  Is this not true for CCS???   Please advise what needs to be changed to fix it Since I used the TI CCS default blank assembly setup, I would not expect to have to get into the complier or linker code.  That is, if the assembly code reported no errors, it should compile, link, and load correctly based on the selected MSP part. Thanks.

**** Build of configuration Debug for project G4_Build ****

"C:\\ti\\ccs1000\\ccs\\utils\\bin\\gmake" -k -j 4 all -O

Building target: "G4_Build.out"

Invoking: MSP430 Linker

"C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/bin/cl430" -vmsp --code_model=small --data_model=small --use_hw_mpy=16 --advice:power=all --define=__MSP430F449__ -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number -z -m"G4_Build.map" --heap_size=0 --stack_size=0 -i"C:/ti/ccs1000/ccs/ccs_base/msp430/include" -i"C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/lib" -i"C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="G4_Build_linkInfo.xml" --entry_point=RESET --use_hw_mpy=16 -o "G4_Build.out" "./main.obj" "../lnk_msp430f449.cmd"  -llibc.a

<Linking>

"../lnk_msp430f449.cmd", line 91: error #10099-D: program will not fit into available memory, or the section contains a call site that requires a trampoline that can't be generated for this section. placement with alignment fails for section ".stack" size 0x2ec2.  Available memory ranges:

   RAM          size: 0x800        unused: 0x800        max hole: 0x800     

error #10010: errors encountered during linking; "G4_Build.out" not built

>> Compilation failure

makefile:141: recipe for target 'G4_Build.out' failed

gmake[1]: *** [G4_Build.out] Error 1

makefile:137: recipe for target 'all' failed

gmake: *** [all] Error 2

 **** Build Finished ****

 

 

  • Hi,

    The error you are experiencing is a linker error, thus not related to the code itself but instead to the process of allocating the data to the device's memory.

    The MSP430F449 device features 2kB (0x800) of RAM, while the error message indicates you are using almost 12kB (0x2EC2) of Stack. 

    Can you check the option on the Project Build options?

    If this parameter is zero, check inside the linker .cmd file for a text that shows -stack <size>. 

    Setting these to the size allocated on the IAR project should be enough to solve this. 

    Hope this helps,

    Rafael

  • I changed the basic options to set the stack size to 100h and the linker build error indicated this stack size.  However, it still reported the same line 91 error  ("fails for section ".stack" size 0x2ec2").  In the IAR system, I used the assembly code instruction

    RESET   mov   $800h,SP  ;initialize stackpointer

    This was the only instruction required.  I don't recall ever having to adjust any other setups, although I am sure they are available for special requirements.  With CCS, there are numerous setup options.  Should I be using an assembly line instruction to set the .stack size?

    Are there any default setups to compile straight forward generic assembly language code based on the assembly code and MSP430 part with no special requirements?  That is, without having to learn about all the configurable "back office" compiler & linker options in order to simply code, compile, build, link, and load a simple error free assembly language program into a MSP430 part. 

    Is there an example you can suggest of such a program that sets everything up so that all I have to do is copy & paste my assembly code into the example as I did using the TI ASM template?  Thanks.        

  • I am referring back to the first post in this thread.

    I don't understand why this happened ...

    Greg Piesinger55 said:
    Invoking: MSP430 Linker

    "C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/bin/cl430" -vmsp --code_model=small --data_model=small --use_hw_mpy=16 --advice:power=all --define=__MSP430F449__ -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number -z -m"G4_Build.map" --heap_size=0 --stack_size=0 -i"C:/ti/ccs1000/ccs/ccs_base/msp430/include" -i"C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/lib" -i"C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="G4_Build_linkInfo.xml" --entry_point=RESET --use_hw_mpy=16 -o "G4_Build.out" "./main.obj" "../lnk_msp430f449.cmd"  -llibc.a

    <Linking>

    "../lnk_msp430f449.cmd", line 91: error #10099-D: program will not fit into available memory, or the section contains a call site that requires a trampoline that can't be generated for this section. placement with alignment fails for section ".stack" size 0x2ec2.  Available memory ranges:

       RAM          size: 0x800        unused: 0x800        max hole: 0x800     

    error #10010: errors encountered during linking; "G4_Build.out" not built

    >> Compilation failure

    I failed to reproduce it.  I'd appreciate if you would put the CCS project back in this state and then submit it.  To create a zip file of the project, please follow the directions in the article Sharing Projects.  Then attach the zip to your next post.

    Thanks and regards,

    -George

  • Thanks George.  Your not being able to reproduce it was a clue for me to try building it with less code.  By eliminating lots of code, it built correctly.  I added back code until adding a single extra line caused it to fail.  The results when it worked are inserted below.  The problem is that the stack still sucks up all the ram.  Note that only 2 bytes of ram are left.  Adding one more line of code gives the linker line 91 error.  The full code runs in IAR, so I am not using all the SP430 ram available.

     

    I notice that CCS is more formal than IAR in coding.  Do I have to declare a .bss or .data section in CCS to prevent this?  There must be some statement in the assembly code in CCS that is not required in IAR to prevent the stack from grabbing all the ram.  The linker reports the stack size is 0100h as I requested.

     

    Does anyone have an assembly language program template that includes all the boiler plate to run correctly, so all I have to do is insert my code?  Thanks.

    Greg  

     

     

     

     

     

    **** Build of configuration Debug for project ti-test ****

     

    "C:\\ti\\ccs1000\\ccs\\utils\\bin\\gmake" -k -j 4 all -O

     

    Building file: "../TI_main.asm"

    Invoking: MSP430 Compiler

    "C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/bin/cl430" -vmsp --code_model=small --data_model=small --near_data=globals --use_hw_mpy=16 --include_path="C:/ti/ccs1000/ccs/ccs_base/msp430/include" --include_path="C:/TI_test" --include_path="C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/include" --advice:power="all" --define=__MSP430F449__ -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --preproc_with_compile --preproc_dependency="TI_main.d_raw" "../TI_main.asm"

    >> WARNING: --near_data is only applicable for large data models. Option ignored.

    Finished building: "../TI_main.asm"

     

    Building target: "ti-test.out"

    Invoking: MSP430 Linker

    "C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/bin/cl430" -vmsp --code_model=small --data_model=small --near_data=globals --use_hw_mpy=16 --advice:power="all" --define=__MSP430F449__ -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number -z -m"ti-test.map" --heap_size=0 --stack_size=0100h -i"C:/ti/ccs1000/ccs/ccs_base/msp430/include" -i"C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/lib" -i"C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="ti-test_linkInfo.xml" --entry_point=RESET --use_hw_mpy=16 -o "ti-test.out" "./TI_main.obj" "../lnk_msp430f449.cmd"  -llibc.a

    <Linking>

    >> WARNING: --near_data is only applicable for large data models. Option ignored.

    Finished building target: "ti-test.out"

     

     

    **** Build Finished ****

     

     

    ******************************************************************************

                      MSP430 Linker PC v20.2.0                    

    ******************************************************************************

    >> Linked Thu Apr 2 08:38:20 2020

     

    OUTPUT FILE NAME: <ti-test.out>

    ENTRY POINT SYMBOL: "RESET" address: 00000200

     

     

    MEMORY CONFIGURATION

     

             name            origin    length      used     unused   attr    fill

    ---------------------- --------  ---------  --------  --------  ----  --------

      SFR                  00000000   00000010  00000000  00000010  RWIX

      PERIPHERALS_8BIT      00000010   000000f0  00000000  000000f0  RWIX

      PERIPHERALS_16BIT     00000100   00000100  00000000  00000100  RWIX

      RAM                   00000200   00000800  000007fe  00000002  RWIX

      INFOB                 00001000   00000080  00000000  00000080  RWIX

      INFOA                 00001080   00000080  00000000  00000080  RWIX

      FLASH                 00001100   0000eee0  00000008  0000eed8  RWIX

      INT00                 0000ffe0 00000002  00000002  00000000  RWIX

      INT01                 0000ffe2   00000002  00000002  00000000  RWIX

      INT02                 0000ffe4   00000002  00000002  00000000  RWIX

      INT03                 0000ffe6   00000002  00000002  00000000  RWIX

      INT04                0000ffe8   00000002  00000002  00000000  RWIX

      INT05                 0000ffea   00000002  00000002  00000000  RWIX

      INT06                 0000ffec   00000002  00000002  00000000  RWIX

      INT07                 0000ffee   00000002  00000002  00000000  RWIX

      INT08                 0000fff0   00000002  00000002  00000000  RWIX

      INT09                 0000fff2   00000002  00000002  00000000  RWIX

      INT10                 0000fff4   00000002  00000002  00000000  RWIX

      INT11                 0000fff6   00000002  00000002  00000000  RWIX

      INT12                 0000fff8   00000002  00000002  00000000  RWIX

      INT13                 0000fffa   00000002  00000002  00000000  RWIX

      INT14                 0000fffc   00000002  00000002  00000000  RWIX

      RESET                 0000fffe   00000002  00000002  00000000  RWIX

     

     

    SECTION ALLOCATION MAP

     

     output                                  attributes/

    section   page    origin      length       input sections

    -------- ----  ----------  ----------   ----------------

    .stack     0    00000200    000007fe    

                      00000200    000007fe     TI_main.obj (.stack)

     

    .text     0    00001100    00000008    

                      00001100    00000008     rts430_eabi.lib : isr_trap.asm.obj (.text:_isr:__TI_ISR_TRAP)

     

    .cinit     0    00001100    00000000     UNINITIALIZED

     

    .binit     0    00001100    00000000    

     

    .init_array

    *         0    00001100    00000000     UNINITIALIZED

     

    BASICTIMER

    *         0    0000ffe0    00000002    

                      0000ffe0    00000002     rts430_eabi.lib : int00.asm.obj (.int00)

     

    PORT2     0    0000ffe2    00000002    

                      0000ffe2    00000002     rts430_eabi.lib : int01.asm.obj (.int01)

     

    USART1TX   0    0000ffe4    00000002    

                      0000ffe4    00000002     rts430_eabi.lib : int02.asm.obj (.int02)

     

    USART1RX   0    0000ffe6    00000002    

                      0000ffe6    00000002     rts430_eabi.lib : int03.asm.obj (.int03)

     

    PORT1     0    0000ffe8    00000002    

                      0000ffe8    00000002     rts430_eabi.lib : int04.asm.obj (.int04)

     

    TIMERA1   0    0000ffea    00000002    

                      0000ffea    00000002     rts430_eabi.lib : int05.asm.obj (.int05)

     

    TIMERA0   0    0000ffec    00000002    

                      0000ffec    00000002    rts430_eabi.lib : int06.asm.obj (.int06)

     

    ADC12     0    0000ffee    00000002    

                      0000ffee    00000002     rts430_eabi.lib : int07.asm.obj (.int07)

     

    USART0TX   0    0000fff0    00000002    

                      0000fff0    00000002   rts430_eabi.lib : int08.asm.obj (.int08)

     

    USART0RX   0    0000fff2    00000002    

                      0000fff2    00000002     rts430_eabi.lib : int09.asm.obj (.int09)

     

    WDT       0    0000fff4    00000002    

                      0000fff4    00000002     rts430_eabi.lib : int10.asm.obj (.int10)

     

    COMPARATORA

    *         0    0000fff6    00000002    

                      0000fff6    00000002     rts430_eabi.lib : int11.asm.obj (.int11)

     

    TIMERB1   0    0000fff8    00000002    

                      0000fff8    00000002     rts430_eabi.lib : int12.asm.obj (.int12)

     

    TIMERB0   0    0000fffa    00000002    

                      0000fffa    00000002     rts430_eabi.lib : int13.asm.obj (.int13)

     

    NMI       0    0000fffc    00000002    

                      0000fffc    00000002     rts430_eabi.lib : int14.asm.obj (.int14)

     

    .reset     0    0000fffe    00000002    

                      0000fffe    00000002     TI_main.obj (.reset)

     

    MODULE SUMMARY

     

           Module             code   ro data   rw data

           ------             ---- -------   -------

        .\

           TI_main.obj        0      2         0     

        +--+------------------+------+---------+---------+

           Total:             0      2         0     

                                                     

        C:\ti\ccs1000\ccs\tools\compiler\ti-cgt-msp430_20.2.0.LTS\lib\rts430_eabi.lib

           isr_trap.asm.obj   8      0         0     

           int00.asm.obj      0      2         0     

           int01.asm.obj      0      2         0     

           int02.asm.obj      0      2         0     

           int03.asm.obj      0      2         0     

           int04.asm.obj      0      2         0     

           int05.asm.obj      0      2         0     

           int06.asm.obj      0      2         0     

           int07.asm.obj      0      2         0     

           int08.asm.obj      0      2         0     

           int09.asm.obj      0      2         0     

           int10.asm.obj      0      2         0     

           int11.asm.obj      0      2         0     

           int12.asm.obj      0      2         0      

           int13.asm.obj      0      2         0     

           int14.asm.obj      0      2         0     

        +--+------------------+------+---------+---------+

           Total:             8      30        0     

                                                    

           Stack:             0      0         2046  

        +--+------------------+------+---------+---------+

           Grand Total:       8      32        2046  

     

     

     

    000009fe __STACK_END        

    000007fe __STACK_SIZE       

    00001100 __TI_ISR_TRAP      

    0000ffe0 __TI_int00         

    0000ffe2 __TI_int01         

    0000ffe4 __TI_int02         

    0000ffe6 __TI_int03         

    0000ffe8 __TI_int04         

    0000ffea __TI_int05         

    0000ffec __TI_int06         

    0000ffee __TI_int07         

    0000fff0 __TI_int08         

    0000fff2 __TI_int09         

    0000fff4 __TI_int10         

    0000fff6 __TI_int11         

    0000fff8 __TI_int12         

    0000fffa __TI_int13         

    0000fffc __TI_int14         

    ffffffff __TI_pprof_out_hndl

    ffffffff __TI_prof_data_size

    ffffffff __TI_prof_data_start

    ffffffff __c_args__         

     

     

  • These lines from the map file ...

    Greg Piesinger55 said:

    .stack     0    00000200    000007fe    

                      00000200    000007fe     TI_main.obj (.stack)

    ... mean that the source file TI_main.asm contains code which creates a .stack section that is 0x7fe bytes long.  

    We in this forum are experts in the compiler, assembler, linker, and related tools.  We are not experts at MSP430 programming.  At this point, that is the help you need.

    Greg Piesinger55 said:
    Does anyone have an assembly language program template that includes all the boiler plate to run correctly, so all I have to do is insert my code?

    I'm not aware of any such example.  I will notify the MSP430 device experts about this thread. 

    Thanks and regards,

    -George

  • Hi Greg,

    there are quite some things available to help you getting easily started with MSP430 coding in assembler.

    The first and probably the easiest are the code examples within CCS and its TI Resource Explorer. Please see here the single steps in screen shots:

    Click the Resource Explorer button. In case you do not see this window, due to previous activities with CCS, go to "View >> Getting Started", then you get this view again.

    Go to "Software". There you can see the "MSP430Ware - xxxx" If there should not be the green button, as visible in my screen shot here, you need to download the MSP430Ware first, before going to the next steps. You can do this by clicking on the MSP430Ware and then picking the "Install" option. Then the installation should start. After successful installation the green button should show up.

    When opening the "MSP430Ware" by clicking on the arrow next to it on the left, you'll be able to got to "Devices >> MSP430F4xx >> MSP430F449"

    From there you can get to "Peripheral Examples >> Assembly" As you can see, you can find quite some code examples there. The first one is usually the most simple one, a so called blinking LED.

    By clicking on it, you can visualize it on the right. In the upper right corner of the source code window, there is an "import" button. By clicking on it, you can trigger an import, which results in importing the source code, including a complete setup of a respective project, fully functional.

    The other method is, again starting from the "Getting Started" view, but clicking on "Create a new project"

    Then in the pop-up window select the to be used device.

    Select a name for the project.

    And select the "empty asm project"

    Then click "Finish"

    Doing so again creates a complete project in assembly, in which you can start adding your code. But all the basic settings for a functional assembly project are already included...

    In addition, there are some documents, which are certainly helpful, when writing code in assembly:

    In this one you can even find hints on how to migrate from IAR assembly to CCS

    And maybe also this document, which explains how to mix assembly and C-code.

    Best regards

    Peter

  • Hi Peter.  Thanks for the links.  Here is my situation.  Although I had to modify my code over the years as some of our probe hardware went obsolete (GPS modules, etc.) I wrote the code in 2004 using IAR tools on a Windows 2000 PC.  It is a large program (8000 lines of assembly code, comments, and lookup tables) that uses nearly every MSP430 assembly instruction available.  The code works fine and is still running on hundreds of probes.  The goal is to migrate the code to a modern Windows 10 PC. 

    I used the TI migration instructions in the PDF you included and obtained an error free assembly build.  The problem is the code won't build due to linker errors.  Obviously, the TI migration instructions and/or the TI blank assembly build template are not complete.

    I will search again, but the only migration post I found was from someone who abandoned trying.  All the MSP430 assembly projects I found are for simple blinking light projects.  An example of a fairly complete working assembly code with build options would be useful.  I have seen an option in the CCS tools for the build to be compatible with earlier versions of CCS.  Would that help, since I believe I used the original IAR tools?

    I will try CCS for a few more days, but it may be more cost effective to simply upgrade to the latest IAR tools.  Thanks.

    Greg 

  • Hi Greg,

    understood. That's of course a more difficult problem as on one hand not possible to reproduce and debug here on our side, without having the entire project, and I know how "helpful" the error messages of IDEs can be.

    I have been using assembler heavily years ago, but also with IAR and not CCS. At the time when I switched to CCS I also switched to mainly C-coding, also due to the obstacles I ran into with CCS assembly nomenclature.

    About switching to IAR latest version, that might be an option. Older MSP430 IAR versions have been for free/unlimited in case of coding in assembly. I am not sure how it is at the moment, but maybe you can find an agreement with IAR, where they make you a special offer on a license without C-Compiler. At least worth trying.

    Beyond that, I'll check with some older colleagues of mine, who also migrated from assembly to C and CCS. Maybe they have an idea how to address the linker problem you're facing.

    Best regards

    Peter

  • Hi Greg,

    good to read that you could already do most of the conversion to CCS.

    Reading through this post does not give all the answers for solving the problem, esp. as some critical code snippets from your code are not available.

    So let us analyze what is there:

    - The linker report gives already most of the answer:

    MEMORY CONFIGURATION

     

             name            origin    length      used     unused   attr    fill

    ---------------------- --------  ---------  --------  --------  ----  --------

      SFR                  00000000   00000010  00000000  00000010  RWIX

      PERIPHERALS_8BIT      00000010   000000f0  00000000  000000f0  RWIX

      PERIPHERALS_16BIT     00000100   00000100  00000000  00000100  RWIX

      RAM                   00000200   00000800  000007fe  00000002  RWIX

      INFOB                 00001000   00000080  00000000  00000080  RWIX

      INFOA                 00001080   00000080  00000000  00000080  RWIX

      FLASH                 00001100   0000eee0  00000008  0000eed8  RWIX

    Your code is not place in the Flash memory region where is should be - used memory  8 - this are most properly some interrupt vectors

    But it looks like it went into the RAM area - this is filled - only two bytes left - most properly the last instruction had more the 2 words and did not fit in anymore.

    - you showed some code in the first post where you said you used this as starting point

    snip.....

    ;-------------------------------------------------------------------------------
    ; Stack Pointer definition
    ;-------------------------------------------------------------------------------
               .global __STACK_END
               .sect   .stack

    RESET           mov.w   #__STACK_END,SP         ; Initialize stackpointer

    So i assume you just continued with writing your code after this lines and that is the problem now.

    The linker always places the code into that section you have given before until you name a new section

    So your code should look like this:

    snip.....

    ;-------------------------------------------------------------------------------
    ; Stack Pointer definition
    ;-------------------------------------------------------------------------------
               .global __STACK_END
               .sect   .stack

        .text                                         ; Assemble into program memory.
                                                      ; tell the linker that the following part
                                                      ; needs to go into the text = Flash section

    RESET           mov.w   #__STACK_END,SP         ; Initialize stackpointer

    ..... continue with code

  • Thanks Stefan, that fixed the RAM problem.  I wrote this code in 2004 using IAR tools which didn't require using sections.  Hopefully you can advise me on the proper way to also define RAM and STACK sections.  Below is my IAR code when converted to CCS.  I start with the TI ASM template and added my code in the "Main Loop Section" of the template.

    ;-------------------------------------------------------------------------------
    ; MSP430 Assembler Code Template for use with TI Code Composer Studio
    ;-------------------------------------------------------------------------------
                .cdecls C,LIST,"msp430.h"       ; Include device header file
                
    ;-------------------------------------------------------------------------------
                .def    RESET        ; Export program entry-point to
                                                ; make it known to linker.
    ;-------------------------------------------------------------------------------
                .text                          ; Assemble into program memory.
                .retain                      ; Override ELF conditional linking
                                                 ; and retain current section.
                .retainrefs               ; And retain any sections that have
                                                 ; references to current section.

    ;-------------------------------------------------------------------------------
    RESET           mov.w   #__STACK_END,SP                         ; Initialize stackpointer
    ;StopWDT      mov.w   #WDTPW|WDTHOLD,&WDTCTL  ; Stop watchdog timer (moved this below)

    ;-------------------------------------------------------------------------------
    ; Main loop here
    ;-------------------------------------------------------------------------------

    ;******************************************************************************
    ;RAM words used for variables
    ;******************************************************************************
    ;
    ;RAM variables (bytes)

    garb                        .equ    0200h    ;garb indicates start of ram
    RX_store_flag      .equ    0201h
    low_bat_flag         .equ    0202h
       (plus many more bytes and words)
    ;-------------------------------------------------------------------------------
    Setup        ;Configure modules and control registers
    ;-------------------------------------------------------------------------------

                                 .align 2
    StopWDT            mov    #WDTPW+WDTHOLD,&WDTCTL        ;stop Watchdog Timer

    SetupFLL2        bis.b    #020h,&FLL_CTL0            ;set load capacitance for xtal (14uf)

                                mov.b    #(64-1),&SCFQCTL        ;2MHz clock
                                mov.b    #FN_2,&SCFI0

    pwr_up_point   call    #Delay2                                 ;Wait about a half second
            (plus many  more instructions)

    ;-------------------------------------------------------------------------------
    ;Interrupt Vectors  (defined my own in IAR)
    ;-------------------------------------------------------------------------------

                .sect   ".reset"                ; MSP430 RESET Vector (This one from TI template)
                .short  RESET
                
                .sect   ".NMI_VECTOR"
                .short  DUMMEY_NMI

                .sect   ".TIMERB0_VECTOR "
                .short    DUMMEY_TIMER_B7_2

                .sect   ".TIMERB1_VECTOR"
                .short    DUMMEY_TIMER_B7_1

                .sect   ".COMPARATORA_VECTOR"  
                .short    COMPARE

                .sect   ".WDT_VECTOR"
                .short    DUMMEY_WATCH_DOG

                .sect   ".USART0RX_VECTOR"      
                .short    USART0RX_ISR

                .sect   ".USART0TX_VECTOR"
                .short    DUMMEY_USART0_TX

                .sect   ".ADC_VECTOR"
                .short    DUMMEY_ADC12

                .sect   ".TIMERA0_VECTOR"
                .short    DUMMEY_TIMER_A3_2

                .sect   ".TIMERA1_VECTOR"
                .short    DUMMEY_TIMER_A3_1

                .sect   ".PORT1_VECTOR"           
                .short    PPS_ISR

                .sect   ".PORT2_VECTOR"          
                .short    SWITCH_ISR

                .sect   ".BASICTIMER_VECTOR"  
                .short    ADC_SAMP

                 .end

    Here is the build results.

    **** Build of configuration Debug for project ti2_test ****

    "C:\\ti\\ccs1000\\ccs\\utils\\bin\\gmake" -k -j 4 all -O
     
    Building file: "../main.asm"
    Invoking: MSP430 Compiler
    "C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/bin/cl430" -vmsp --code_model=small --data_model=small --use_hw_mpy=16 --include_path="C:/ti/ccs1000/ccs/ccs_base/msp430/include" --include_path="C:/TI2_test" --include_path="C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/include" --advice:power=all --define=__MSP430F449__ -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number --preproc_with_compile --preproc_dependency="main.d_raw"  "../main.asm"
    Finished building: "../main.asm"
     
    Building target: "ti2_test.out"
    Invoking: MSP430 Linker
    "C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/bin/cl430" -vmsp --code_model=small --data_model=small --use_hw_mpy=16 --advice:power=all --define=__MSP430F449__ -g --printf_support=minimal --diag_warning=225 --diag_wrap=off --display_error_number -z -m"ti2_test.map" --heap_size=0 --stack_size=0200h -i"C:/ti/ccs1000/ccs/ccs_base/msp430/include" -i"C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/lib" -i"C:/ti/ccs1000/ccs/tools/compiler/ti-cgt-msp430_20.2.0.LTS/include" --reread_libs --diag_wrap=off --display_error_number --warn_sections --xml_link_info="ti2_test_linkInfo.xml" --entry_point=RESET --use_hw_mpy=16 -o "ti2_test.out" "./main.obj" "../lnk_msp430f449.cmd"  -llibc.a
    <Linking>
    warning #10247-D: creating output section ".NMI_VECTOR" without a SECTIONS specification
    warning #10247-D: creating output section ".TIMERB0_VECTOR " without a SECTIONS specification
    warning #10247-D: creating output section ".TIMERB1_VECTOR" without a SECTIONS specification
    warning #10247-D: creating output section ".COMPARATORA_VECTOR" without a SECTIONS specification
    warning #10247-D: creating output section ".WDT_VECTOR" without a SECTIONS specification
    warning #10247-D: creating output section ".USART0RX_VECTOR" without a SECTIONS specification
    warning #10247-D: creating output section ".USART0TX_VECTOR" without a SECTIONS specification
    warning #10247-D: creating output section ".ADC_VECTOR" without a SECTIONS specification
    warning #10247-D: creating output section ".TIMERA0_VECTOR" without a SECTIONS specification
    warning #10247-D: creating output section ".TIMERA1_VECTOR" without a SECTIONS specification
    warning #10247-D: creating output section ".PORT1_VECTOR" without a SECTIONS specification
    warning #10247-D: creating output section ".PORT2_VECTOR" without a SECTIONS specification
    warning #10247-D: creating output section ".BASICTIMER_VECTOR" without a SECTIONS specification
    Finished building target: "ti2_test.out"
     

    **** Build Finished ****

    Here is the map.

    ******************************************************************************
                      MSP430 Linker PC v20.2.0                     
    ******************************************************************************
    >> Linked Wed Apr  8 10:26:39 2020

    OUTPUT FILE NAME:   <ti2_test.out>
    ENTRY POINT SYMBOL: "RESET"  address: 00001100


    MEMORY CONFIGURATION

             name            origin    length      used     unused   attr    fill
    ----------------------  --------  ---------  --------  --------  ----  --------
      SFR                   00000000   00000010  00000010  00000000  RWIX
      PERIPHERALS_8BIT      00000010   000000f0  0000000a  000000e6  RWIX
      PERIPHERALS_16BIT     00000100   00000100  00000000  00000100  RWIX
      RAM                   00000200   00000800  00000200  00000600  RWIX
      INFOB                 00001000   00000080  00000000  00000080  RWIX
      INFOA                 00001080   00000080  00000000  00000080  RWIX
      FLASH                 00001100   0000eee0  00002eca  0000c016  RWIX
      INT00                 0000ffe0   00000002  00000002  00000000  RWIX
      INT01                 0000ffe2   00000002  00000002  00000000  RWIX
      INT02                 0000ffe4   00000002  00000002  00000000  RWIX
      INT03                 0000ffe6   00000002  00000002  00000000  RWIX
      INT04                 0000ffe8   00000002  00000002  00000000  RWIX
      INT05                 0000ffea   00000002  00000002  00000000  RWIX
      INT06                 0000ffec   00000002  00000002  00000000  RWIX
      INT07                 0000ffee   00000002  00000002  00000000  RWIX
      INT08                 0000fff0   00000002  00000002  00000000  RWIX
      INT09                 0000fff2   00000002  00000002  00000000  RWIX
      INT10                 0000fff4   00000002  00000002  00000000  RWIX
      INT11                 0000fff6   00000002  00000002  00000000  RWIX
      INT12                 0000fff8   00000002  00000002  00000000  RWIX
      INT13                 0000fffa   00000002  00000002  00000000  RWIX
      INT14                 0000fffc   00000002  00000002  00000000  RWIX
      RESET                 0000fffe   00000002  00000002  00000000  RWIX


    SECTION ALLOCATION MAP

     output                                  attributes/
    section   page    origin      length       input sections
    --------  ----  ----------  ----------   ----------------
    .stack     0    00000800    00000200     
                      00000800    00000200     --HOLE-- [fill = 0]

    .text      0    00001100    00002eca     
                      00001100    00002ec2     main.obj (.text)
                      00003fc2    00000008     rts430_eabi.lib : isr_trap.asm.obj (.text:_isr:__TI_ISR_TRAP)

    .cinit     0    00001100    00000000     UNINITIALIZED

    .binit     0    00001100    00000000     

    .init_array
    *          0    00001100    00000000     UNINITIALIZED

    .ADC_VECTOR
    *          0    00000000    00000002     
                      00000000    00000002     main.obj (.ADC_VECTOR)

    .BASICTIMER_VECTOR
    *          0    00000002    00000002     
                      00000002    00000002     main.obj (.BASICTIMER_VECTOR)

    .COMPARATORA_VECTOR
    *          0    00000004    00000002     
                      00000004    00000002     main.obj (.COMPARATORA_VECTOR)

    .PORT1_VECTOR
    *          0    00000008    00000002     
                      00000008    00000002     main.obj (.PORT1_VECTOR)

    .PORT2_VECTOR
    *          0    0000000a    00000002     
                      0000000a    00000002     main.obj (.PORT2_VECTOR)

    .TIMERA0_VECTOR
    *          0    0000000c    00000002     
                      0000000c    00000002     main.obj (.TIMERA0_VECTOR)

    .TIMERA1_VECTOR
    *          0    0000000e    00000002     
                      0000000e    00000002     main.obj (.TIMERA1_VECTOR)

    .USART0RX_VECTOR
    *          0    00000014    00000002     
                      00000014    00000002     main.obj (.USART0RX_VECTOR)

    .USART0TX_VECTOR
    *          0    00000016    00000002     
                      00000016    00000002     main.obj (.USART0TX_VECTOR)

    BASICTIMER
    *          0    0000ffe0    00000002     
                      0000ffe0    00000002     rts430_eabi.lib : int00.asm.obj (.int00)

    PORT2      0    0000ffe2    00000002     
                      0000ffe2    00000002     rts430_eabi.lib : int01.asm.obj (.int01)

    USART1TX   0    0000ffe4    00000002     
                      0000ffe4    00000002     rts430_eabi.lib : int02.asm.obj (.int02)

    USART1RX   0    0000ffe6    00000002     
                      0000ffe6    00000002     rts430_eabi.lib : int03.asm.obj (.int03)

    PORT1      0    0000ffe8    00000002     
                      0000ffe8    00000002     rts430_eabi.lib : int04.asm.obj (.int04)

    TIMERA1    0    0000ffea    00000002     
                      0000ffea    00000002     rts430_eabi.lib : int05.asm.obj (.int05)

    TIMERA0    0    0000ffec    00000002     
                      0000ffec    00000002     rts430_eabi.lib : int06.asm.obj (.int06)

    ADC12      0    0000ffee    00000002     
                      0000ffee    00000002     rts430_eabi.lib : int07.asm.obj (.int07)

    USART0TX   0    0000fff0    00000002     
                      0000fff0    00000002     rts430_eabi.lib : int08.asm.obj (.int08)

    USART0RX   0    0000fff2    00000002     
                      0000fff2    00000002     rts430_eabi.lib : int09.asm.obj (.int09)

    WDT        0    0000fff4    00000002     
                      0000fff4    00000002     rts430_eabi.lib : int10.asm.obj (.int10)

    COMPARATORA
    *          0    0000fff6    00000002     
                      0000fff6    00000002     rts430_eabi.lib : int11.asm.obj (.int11)

    TIMERB1    0    0000fff8    00000002     
                      0000fff8    00000002     rts430_eabi.lib : int12.asm.obj (.int12)

    TIMERB0    0    0000fffa    00000002     
                      0000fffa    00000002     rts430_eabi.lib : int13.asm.obj (.int13)

    NMI        0    0000fffc    00000002     
                      0000fffc    00000002     rts430_eabi.lib : int14.asm.obj (.int14)

    .reset     0    0000fffe    00000002     
                      0000fffe    00000002     main.obj (.reset)

    .NMI_VECTOR
    *          0    00000006    00000002     
                      00000006    00000002     main.obj (.NMI_VECTOR)

    .TIMERB0_VECTOR  
    *          0    00000010    00000002     
                      00000010    00000002     main.obj (.TIMERB0_VECTOR )

    .TIMERB1_VECTOR
    *          0    00000012    00000002     
                      00000012    00000002     main.obj (.TIMERB1_VECTOR)

    .WDT_VECTOR
    *          0    00000018    00000002     
                      00000018    00000002     main.obj (.WDT_VECTOR)

    MODULE SUMMARY

           Module             code    ro data   rw data
           ------             ----    -------   -------
        .\
           main.obj           11970   28        0      
        +--+------------------+-------+---------+---------+
           Total:             11970   28        0      
                                                       
        C:\ti\ccs1000\ccs\tools\compiler\ti-cgt-msp430_20.2.0.LTS\lib\rts430_eabi.lib
           isr_trap.asm.obj   8       0         0      
           int00.asm.obj      0       2         0      
           int01.asm.obj      0       2         0      
           int02.asm.obj      0       2         0      
           int03.asm.obj      0       2         0      
           int04.asm.obj      0       2         0      
           int05.asm.obj      0       2         0      
           int06.asm.obj      0       2         0      
           int07.asm.obj      0       2         0      
           int08.asm.obj      0       2         0      
           int09.asm.obj      0       2         0      
           int10.asm.obj      0       2         0      
           int11.asm.obj      0       2         0      
           int12.asm.obj      0       2         0      
           int13.asm.obj      0       2         0      
           int14.asm.obj      0       2         0      
        +--+------------------+-------+---------+---------+
           Total:             8       30        0      
                                                       
           Stack:             0       0         512    
        +--+------------------+-------+---------+---------+
           Grand Total:       11978   58        512    


    GLOBAL SYMBOLS: SORTED ALPHABETICALLY BY Name

    address   name                
    -------   ----                
    000001a0  ADC12CTL0 

    (plus many more from header file)

    **************************************************************

    I set the stack to 0200h, and that is all I got.  That is, all the variables I defined, along with their address don't appear in the RAM space.  Only the 0200h I ask for the stack.

    I also got all the vectors I added plus all the ones defined in the header file.  I would like to use my names.  Do I need to remove the TI defined names in the header file?  Otherwise, I will have to change the names in my code.

    Any comments or suggestions you can offer will be greatly appreciated.  Thanks.

    Greg

  • Hi Greg,

    good that you could solve your initial problem. I now see also that you have done all the code placement manually in IAR and did not use the linker to make that job for you.

    To get the other things addressed i put below a code template. I hope that this will help you to solve the remaining parts.

    ;-------------------------------------------------------------------------------
    ; MSP430 Assembler Code Template for use with TI Code Composer Studio
    ;
    ;
    ;-------------------------------------------------------------------------------
                .cdecls C,LIST,"msp430.h"       ; Include device header file
                
    ;-------------------------------------------------------------------------------
                .def    RESET                   ; Export program entry-point to
                                                ; make it known to linker.
    ;-------------------------------------------------------------------------------
    ; Constants
                .sect ".const"                  ; use the data section to place constants
    WordConst1  .uword 0xABCD
    WordConst2  .uword 0x1234
    ByteConst1  .byte    0x12
                .align 2                        ; use align between byte and word to get the next word aligned
    WordConst3  .uword 0x3333


    ;-------------------------------------------------------------------------------
    ; Variables
                .bss    var1,2                  ; allocate var1 with a size of 2 bytes
                .bss    var2,1                  ; allocate var2 with a size of 1 byte
                .bss    var3,2                  ; allocate var2 with a size of 2 bytes

    ;-------------------------------------------------------------------------------
                .text                           ; Assemble into program memory.
                .retain                         ; Override ELF conditional linking
                                                ; and retain current section.
                .retainrefs                     ; And retain any sections that have
                                                ; references to current section.

    ;-------------------------------------------------------------------------------
    RESET       mov.w   #__STACK_END,SP         ; Initialize stackpointer
    StopWDT     mov.w   #WDTPW|WDTHOLD,&WDTCTL  ; Stop watchdog timer


    ;-------------------------------------------------------------------------------
    ; Main loop here
    ;-------------------------------------------------------------------------------
                your code .....
                                                

    ;-------------------------------------------------------------------------------
    ; Stack Pointer definition
    ;-------------------------------------------------------------------------------
                .global __STACK_END
                .sect   .stack
                
    ;-------------------------------------------------------------------------------
    ; Interrupt Vectors
    ;-------------------------------------------------------------------------------
                .sect   ".reset"                ; MSP430 RESET Vector
                .short  RESET
               
                add your interrupt table

    Using this methods, e.g. for the placement of the variables - the linker does all the job of the address calculation for you. So when you add or change anything it will automatically align and calculate the addresses.

    Ok, now to your other questions.

    - your variables are not showing with the method you used as this is not done by the Linker but manually assigning values to variables.

    - i do not recommend to change the names in the header file - keeping this will maintain portability and also using updates of the environment.
    I guess what you would like to do is this, e.g. for the UART ISR:
                .sect   ".USART0RX_VECTOR"           ; -> this is the name and location of the vector you will get from the device header file
                                                                                     -> do not change this name
                .short    USART0RX_ISR                      ; -> this is the name of the function to be called when this interrupt is activated
                                                                                     -> this name you can freely choose so use your names here

    ~ Stefan

  • Thanks Stefan.  Your template is exactly what I was looking for.  In 2004 when I wrote the initial code, the IAR tools were very simple to use.  It was not necessary to know anything about linkers, sections, etc. etc. as IAR handled all this "back office" stuff automatically.  Therefore, the programmer could concentrate on bit mapping MSP430 pins to PWB hardware components, their setup routines, and overall end product features.

    Your template should allow me to complete the IAR to CCS migration.  I very much appreciate your help.  Thanks.

    Greg