簡體   English   中英

如何在Code Composer Studio(CCS)中為TI MSP432系列創建僅匯編項目

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

我可以復制一些現有的組裝項目,但是有很多與此相關的文件,我想知道它們是否有必要。

重述此問題的另一種方法是,我想設置CCS或Eclipse來構建/安裝/調試MSP432 Launchpad開發板,這是最少的步驟和文件。

我問是因為我(將作為另一個問題發帖)想設置一個中斷(僅在匯編中)以捕獲GPIO端口上的輸入。

我已經讀了很多理論,但是它們並沒有轉化為實際的特定步驟。

更新:

對於STM32 Nucleo,這非常簡單。 使用arm gcc,gdb和st-link,只需要兩個文件。 這是一個示例,顯示了一些在重置處理程序中運行的代碼。 但是MSP432似乎更復雜。

文件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
}

文件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

編譯:

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

鏈接:

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

更新:希望這對我有幫助的,如果我可以決定消除哪些需求,需要進行哪些修改。 這是我一直在復制的Code Composer中的一個匯編項目。 在該項目樹中,“ Assembly.asm”是我一直使用的文件。 它有我的代碼和指令。 AssemblyProject

以下是當前項目的編譯器包含選項: 編譯器包含選項

- 謝謝

這可能很痛苦,因為CCS對此處理器上的裝配項目沒有任何現成的支持。 我教一個嵌入式系統課程,在那里我們為432編寫匯編代碼,因此我需要自己弄清楚這一點。 這是我修改CCS項目並使之與匯編代碼一起使用的工作:

  • 修改了編譯器的“包含選項”以刪除默認的包含路徑(但必須保留“項目根”):

    • ROOT /臂/包括
    • ROOT /臂/包含/ CMSIS
    • ROOT /包括
  • 鏈接器文件搜索路徑選項已修改,可將libc.a刪除為默認庫文件。

  • 鏈接器文件搜索路徑選項已修改,以刪除默認的包含路徑:

    • ROOT /臂/包括
    • ROOT /臂/包含/ CMSIS
    • ROOT /包括
  • 在Build選項中添加了一個后構建步驟,以創建反匯編的代碼清單:

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

  • 啟用了用於keep the generated assemblygenerate listing file的匯編程序選項

  • 修改了鏈接程序的符號管理,以將程序入口點設置為Reset_Handler 這只是我對復位向量的首選名稱。

  • 鏈接程序診斷消息10063被視為備注,並且啟用了發出備注的選項。 診斷10063通常是警告入口點符號已更改。

  • 已為編譯器和鏈接器啟用詳細診斷。

修改項目首選項后,還需要創建一個定義中斷向量的程序集文件。 該代碼類似於:

__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

對於其余的異常和中斷,依此類推。 然后創建虛擬處理程序,以后可以覆蓋它們:

Reset_Handler:  .asmfunc
   B $
  .endasmfunc

  .weak Reset_Handler
  .global Reset_Handler

如果查看msp.h頭文件,則可以看到如何為內部寄存器(例如控制GPIO端口的寄存器)的地址創建各種常量標識符。 您需要將它們轉換為計划使用的任何寄存器的匯編語言,然后將這些文件合並到您的項目中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM