在CCS上生成.bin .hex .txt文件並燒錄到MSP430 使LCD燈亮


在CCS上生成.bin .hex .txt文件並燒錄到MSP430 使LCD燈亮

 摘自    https://www.cnblogs.com/binglmm/p/9629618.html       做了小小補充。

 

 

1,在CCS上正確創建工程文件。

新建工程:File-New-CCS Project

2,在main.c文件中編寫程序並保存。

復制代碼
復制代碼
 1 #include <msp430f169.h>
 2 /*
 3  * 軟件延時
 4  */
 5 #define CPU_F1 ((double)1000000)
 6 #define delay_us1M(x) __delay_cycles((long)(CPU_F1*(double)x/1000000.0))
 7 #define delay_ms1M(x) __delay_cycles((long)(CPU_F1*(double)x/1000.0))
 8 
 9 /**
10  * main.c
11  */
12 int main(void)
13 {
14     unsigned char j,k;
15     WDTCTL = WDTPW + WDTHOLD;//關看門狗
16     P6DIR = 0xff;//設置P4端口為輸出端口
17     while(1)
18     {
19         k = 1;
20         for(j=0;j<8;j++)//循環8次,即D1~D8輪流點亮
21         {
22             P6OUT = ~k;//反相輸出,低電平點亮LED
23             delay_ms1M(300);//延時
24             k=k<<1;//左移一位
25         }
26     }
27 
28 }
復制代碼
復制代碼

3編譯程序:Project-Build All

4,配置CCS使其產生.hex可執行文件(用Protues仿真時下載芯片的是.hex文件)

Project-Properties-MSP430 Hex Utility 

勾選 Enable MSP430 Hex Utility 再 Apply and Close 運用並關閉

5,此時再次去編譯程序,會產生.hex文件

結果:

**** Build of configuration Debug for project LCD ****

"D:\\TI\\ccsv8\\utils\\bin\\gmake" -k -j 4 all -O 

gmake[1]: 'LCD.out' is up to date.
Building files: "LCD.out"
Invoking: MSP430 Hex Utility
"D:/TI/ccsv8/tools/compiler/ti-cgt-msp430_18.1.2.LTS/bin/hex430" --memwidth=8 --romwidth=8 -o "LCD.hex""LCD.out" 
Translating to Extended Tektronix format...
"LCD.out" .text ==> .text
"LCD.out" DACDMA ==> DACDMA
"LCD.out" PORT2 ==> PORT2
"LCD.out" USART1TX ==> USART1TX
"LCD.out" USART1RX ==> USART1RX
"LCD.out" PORT1 ==> PORT1
"LCD.out" TIMERA1 ==> TIMERA1
"LCD.out" TIMERA0 ==> TIMERA0
"LCD.out" ADC12 ==> ADC12
"LCD.out" USART0TX ==> USART0TX
"LCD.out" USART0RX ==> USART0RX
"LCD.out" WDT ==> WDT
"LCD.out" COMPARATORA ==> COMPARATORA
"LCD.out" TIMERB1 ==> TIMERB1
"LCD.out" TIMERB0 ==> TIMERB0
"LCD.out" NMI ==> NMI
"LCD.out" .reset ==> .reset
Finished building: "LCD.out"

**** Build Finished ****

6,再次對CCS進行配置,將.hex文件轉換成.txt文件,具體步驟如下:

a、 點擊Project ,選擇Properties; 
b、選擇  Build - Steps 
c、在Post-build steps中加入下列語句,運用並關閉即可:
"${CG_TOOL_HEX}" --ti_txt "${BuildArtifactFileName}" -o "${BuildArtifactFileBaseName}.txt" -order MS -romwidth 16

7,再次編譯程序,將產生.txt文件(可能會有編譯無效,再進去看看配置的情況,然后在編譯。也可以去工程文件夾中看看是否生成.txt文件)

結果:

**** Build of configuration Debug for project LCD ****

"D:\\TI\\ccsv8\\utils\\bin\\gmake" -k -j 4 all -O 

gmake[1]: 'LCD.out' is up to date.
Building files: "LCD.out"
Invoking: MSP430 Hex Utility
"D:/TI/ccsv8/tools/compiler/ti-cgt-msp430_18.1.2.LTS/bin/hex430" --memwidth=8 --romwidth=8 -o "LCD.hex" "LCD.out" 
Translating to Extended Tektronix format...
"LCD.out" .text ==> .text
"LCD.out" DACDMA ==> DACDMA
"LCD.out" PORT2 ==> PORT2
"LCD.out" USART1TX ==> USART1TX
"LCD.out" USART1RX ==> USART1RX
"LCD.out" PORT1 ==> PORT1
"LCD.out" TIMERA1 ==> TIMERA1
"LCD.out" TIMERA0 ==> TIMERA0
"LCD.out" ADC12 ==> ADC12
"LCD.out" USART0TX ==> USART0TX
"LCD.out" USART0RX ==> USART0RX
"LCD.out" WDT ==> WDT
"LCD.out" COMPARATORA ==> COMPARATORA
"LCD.out" TIMERB1 ==> TIMERB1
"LCD.out" TIMERB0 ==> TIMERB0
"LCD.out" NMI ==> NMI
"LCD.out" .reset ==> .reset
Finished building: "LCD.out"

"D:/TI/ccsv8/tools/compiler/ti-cgt-msp430_18.1.2.LTS/bin/hex430" --ti_txt "LCD.out" -o "LCD.txt" -order MS -romwidth 16
Translating to TI-TXT format...
"LCD.out" .text ==> .text
"LCD.out" DACDMA ==> DACDMA
"LCD.out" PORT2 ==> PORT2
"LCD.out" USART1TX ==> USART1TX
"LCD.out" USART1RX ==> USART1RX
"LCD.out" PORT1 ==> PORT1
"LCD.out" TIMERA1 ==> TIMERA1
"LCD.out" TIMERA0 ==> TIMERA0
"LCD.out" ADC12 ==> ADC12
"LCD.out" USART0TX ==> USART0TX
"LCD.out" USART0RX ==> USART0RX
"LCD.out" WDT ==> WDT
"LCD.out" COMPARATORA ==> COMPARATORA
"LCD.out" TIMERB1 ==> TIMERB1
"LCD.out" TIMERB0 ==> TIMERB0
"LCD.out" NMI ==> NMI
"LCD.out" .reset ==> .reset

**** Build Finished ****

 

8,我們用BSL430來進行程序的燒錄,就是將我們得到的.txt文件傳錄到芯片,控制CPU工作

SF_BSL430下載軟件鏈接:https://pan.baidu.com/s/1tumqUGFZhx_83ynXRS3Ugw

 下載好后我們以管理員身份運行應用程序。

(1),選擇串口號(此前還需安裝USB轉串口驅動 CH340或CH341 鏈接:https://pan.baidu.com/s/1DvtcWuatTF9EtwSaBLhbog)

 進計算機管理系統-設備管理器 -端口查找串口號(必須鏈接開發板並上電開啟)

(2),裝載燒錄文件。

到工程文件夾中-Debug文件夾找到.txt文件

(3),執行(可能會編程失敗,重新裝載文件試試)

 

 

 

 

 

注:第5至8 可用一條語句直接輸出 .bin .hex .txt文件

.進入工程配置選項,CCS Build --> Steps ,如圖1所示

 

圖1 CCS工程編譯配置界面

 

在圖1中的Command選項框中(紅色圈出部分),輸入如下命令(沒有換行符):

"${CCE_INSTALL_ROOT}/utils/tiobj2bin/tiobj2bin" "${BuildArtifactFileName}" "${BuildArtifactFileBaseName}.bin" "${CG_TOOL_ROOT}/bin/armofd" "${CG_TOOL_ROOT}/bin/armhex" "${CCE_INSTALL_ROOT}/utils/tiobj2bin/mkhex4bin" & "${CG_TOOL_HEX}" -i "${BuildArtifactFileName}" -o "${BuildArtifactFileBaseName}.hex" -order MS -romwidth 32 & "${CG_TOOL_HEX}" --ti_txt "${BuildArtifactFileName}" -o "${BuildArtifactFileBaseName}.txt" -order MS -romwidth 32

  保存配置,重新clear工程,再次編譯即可同時生成.bin和.hex和.txt文件。

**** Build Finished ****

 

摘自    https://www.cnblogs.com/binglmm/p/9629618.html       做了小小補充。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM