Electronic – How to tell CCS debugger where to start

assemblymsp430ti-ccstudio

I am just starting with MSP430 and Code Composer Studio (CCS).

I want to make a pure-assembly project. At the moment, I have a "hello world" program that does nothing but light an LED on the MSP430F5529 Launchpad.

However, when I run this program in the debugger, execution begins at address 0x0000 instead of at my designated entry point, called RESET (0x10000). I can see that PC is intially set to 0x0000. If I manually set it in the watch window to RESET, the program runs as expected.

I have declared RESET to be global, and I have set the linker option to make RESET the entry point.

I'm guessing I have a problem with either debugger settings or the (boot)loader, but I could be totally on the wrong track.

            .cdecls C,LIST,"msp430.h"       ; Include device header file
    ;-------------------------------------------------------------------------------
            .text                           ; Assemble into program memory
            .retain                         ; Override ELF conditional linking
                                            ; and retain current section
            .retainrefs                     ; Additionally retain any sections
                                            ; that have references to current
                                            ; section
;-------------------------------------------------------------------------------
            .global RESET
RESET       mov.w   #__STACK_END,SP         ; Initialize stackpointer
StopWDT     mov.w   #WDTPW|WDTHOLD,&WDTCTL  ; Stop watchdog timer

;-------------------------------------------------------------------------------
                                            ; Main loop here
            bis.b #01h, &P1DIR
            bis.b #01h, &P1OUT
;-------------------------------------------------------------------------------
;           Stack Pointer definition
;-------------------------------------------------------------------------------
            .global __STACK_END
            .sect   .stack

;-------------------------------------------------------------------------------
;           Interrupt Vectors
;-------------------------------------------------------------------------------
            .sect   ".reset"                ; MSP430 RESET Vector
            .short  RESET

Best Answer

I haven't programmed an MSP430 in assembly, but it seems like the program entry point is not written to the address 0xFFFE:

Program counter (PC) is loaded with the boot code address and boot code execution begins at that address. See Section 1.9 for more information regarding the boot code. Upon completion of the boot code, the PC is loaded with the address contained at the SYSRSTIV reset location (0FFFEh).

So from your description, you are using --entry_point= global_symbol as an option to set the entry point. I can't really see why that wouldn't work, have you checked the actual linker call if that option is applied?

So another option would be to write to the address 0xFFFE the value of your start address. Or at least check in your resulting hex image what value gets written there.

I just found this:

MEMORY
{
    MEM : origin = 0x0200, length = 0xFDFD
    RESET : origin = 0xFFFE, length = 0x0002
}
SECTIONS
{
    .text : {} > MEM
    .const : {} > MEM
    .data : {} > MEM
    .bss : {} > MEM
    .reset : > RESET
    .cinit : {} > MEM ;cflag option only
    .pinit : {} > MEM ;cflag option only
}

as the default placement. So maybe because you also named you label RESET the linker gets confused in some way? Maybe name your entry point differently like START or ENTRY. But this also gives a hint how to get the actual address where you want it. You just have to define a 16 bit constant to be placed in the .reset section.

It's strange how different the TI assembler is from the IAR one, with which I'm a bit more familiar.