how to create an assembly-only project in Code Composer Studio (CCS) for TI MSP432 series

0

I can copy some existing assembly project, however there are a lot files associated with it that I wonder if they are necessary.

Another way of re-phrasing this question would be, is I wanted to set up either CCS or Eclipse to build/install/debug an MSP432 Launchpad development board, what would be the minimum steps and files.

I ask because I (will post as another question) want to set up an interrupt (in assembly only) for capturing input on GPIO port.

I have read plenty of the theory, but they don't translate to the actual, specific steps.

UPDATE:

For an STM32 Nucleo, it's very simple. Using arm gcc, gdb, and st-link, just need two files. Here's an example showing some code running in the reset handler. But the MSP432 seems more complicated.

file linker.script.ld:

/* Define the end of RAM and limit of stack memory */
/* (4KB SRAM on the STM32F031x6 line, 4096 = 0x1000) */
/* (RAM starts at address 0x20000000)
_estack = 0x20001000;

MEMORY
{
    FLASH ( rx )      : ORIGIN = 0x08000000, LENGTH = 32K
    RAM ( rxw )       : ORIGIN = 0x20000000, LENGTH = 4K
}

file core.S:

/*************************************************************************
* PART 1 - SETUP - DIRECTIVES
*************************************************************************/

// These instructions define attributes of our chip and

// the assembly language we'll use:
.syntax unified        /* See below after this code area */
/*.cpu cortex-m0 */ /*comment out this line of the example */
.cpu cortex-m4     /* add instead our board's cortex. see above image in this step */

/*.fpu softvfp */ /* comment out this line of the example */
.fpu vfpv4         /* add instead our board's; it does have an FPU */

.thumb

// Global memory locations.
.global vtable
.global reset_handler

/*
 * The actual vector table.
 * Only the size of RAM and 'reset' handler are
 * included, for simplicity.
 */
.type vtable, %object
vtable:
    .word _estack
    .word reset_handler
.size vtable, .-vtable



/*************************************************************************
* PART 2 - CODE - Hello World
*************************************************************************/

/*
 * The Reset handler. Called on reset.
 */
.type reset_handler, %function
reset_handler:
  // Set the stack pointer to the end of the stack.
  // The '_estack' value is defined in our linker script.
  LDR  r0, =_estack
  MOV  sp, r0

  // Set some dummy values. When we see these values
  // in our debugger, we'll know that our program
  // is loaded on the chip and working.
  LDR  r7, =0xDEADBEEF
  MOVS r0, #0
  main_loop:
    // Add 1 to register 'r0'.
    ADDS r0, r0, #1
    // Loop back.
    B    main_loop
.size reset_handler, .-reset_handler

compile:

arm-none-eabi-gcc -x assembler-with-cpp -c -O0 -mcpu=cortex-m0 -mthumb -Wall core.S -o core.o

link:

arm-none-eabi-gcc core.o -mcpu=cortex-m0 -mthumb -Wall --specs=nosys.specs -nostdlib -lgcc -T./STM32F031K6T6.ld -o main.elf

UPDATE: hopefully this will help, if I can decide what needs eliminating, what needs modifying. This is an assembly project in Code Composer I've been copying from. In that project tree, the "Assembly.asm" is file I have always worked with. It has my code and directives. AssemblyProject

Here are current project compiler include options: Compiler Include Options

--thank you

assembly
arm
microcontroller
code-composer
msp432
asked on Stack Overflow Oct 16, 2018 by ecorrales • edited Oct 24, 2018 by ecorrales

1 Answer

1

This can be painful, because CCS doesn't have any out-of-the-box support for assembly projects on this processor. I teach an embedded systems class where we write assembly code for the 432 so I needed to figure this out myself. Here's what I have done to modify a CCS project and make it work with assembly code:

  • The compiler Include Options are modified to remove the default include paths (but the PROJECT ROOT must be retained):

    • ROOT/arm/include
    • ROOT/arm/include/cmsis
    • ROOT/include
  • The linker File Search Path options were modified to remove libc.a as a default library file.

  • The linker File Search Path options were modified to remove the default include paths:

    • ROOT/arm/include
    • ROOT/arm/include/cmsis
    • ROOT/include
  • A post-build step is added to the Build options to create the disassembled listing of the code:

    ${CG_TOOL_ROOT}/bin/armdis ${ProjName}.out ${ProjName}.dis

  • The Assembler Options to keep the generated assembly and generate listing file are enabled

  • The Symbol Management for the linker was modified to set the program entry-point to Reset_Handler. This is just my preferred name for the reset vector.

  • Linker diagnostic message 10063 is treated as a remark and the option to issue remarks is enabled. Diagnostic 10063 is normally a warning that the entry-point symbol has been changed.

  • Verbose diagnostics are enabled for both the compiler and the linker.

Once you have modified the project preferences you will also need to create an assembly file that defines the interrupt vectors. That code looks something like:

__STACK_END .equ 0x20010000

  .word __STACK_END         ; Initial Stack Pointer
  .word Reset_Handler       ; Start of executable code
  .word NMI_Handler         ; Non-maskable Interrupt Handler
  .word HardFault_Handler   ; Hard Fault Handler
  .word MemManage_Handler   ; MPU Fault Handler
  .word BusFault_Handler    ; Bus Fault Handler
  .word UsageFault_Handler  ; Usage Fault Handler

and so on for the rest of the exceptions and interrupts. Then you create dummy handlers that can be overwritten later:

Reset_Handler:  .asmfunc
   B $
  .endasmfunc

  .weak Reset_Handler
  .global Reset_Handler

If you look at the msp.h header files you can see how various constant identifiers were created for the addresses of internal registers, such as the registers that control the GPIO ports. You need to convert those to assembly language for whatever registers you plan to use, then incorporate those files into your project.

answered on Stack Overflow Oct 16, 2018 by Elliot Alderson • edited Oct 16, 2018 by Elliot Alderson

User contributions licensed under CC BY-SA 3.0