感谢此应用由 昵称xiaobingzzh 提供。
由于CCS平台程序编译后将直接产生.out文件用于仿真器程序下载,而当在MSP430单片机开发时,可能需要用到BSL下载,此时就需要生成.txt文件用于BSL程序烧录。
本片简述如何在CCS上编辑单片机程序产生.txt文件并采用BSL将程序烧录单片机。(版本为CCS8.1.0)
1,在CCS上正确创建工程文件。
新建工程:File->New->CCS Project
2,在main.c文件中编写程序并保存。
- #include <msp430f169.h>
- /*
- * 软件延时
- */
- #define CPU_F1 ((double)1000000)
- #define delay_us1M(x) __delay_cycles((long)(CPU_F1*(double)x/1000000.0))
- #define delay_ms1M(x) __delay_cycles((long)(CPU_F1*(double)x/1000.0))
- /**
- * main.c
- */
- int main(void)
- {
- unsigned char j,k;
- WDTCTL = WDTPW + WDTHOLD;//关看门狗
- P6DIR = 0xff;//设置P4端口为输出端口
- while(1)
- {
- k = 1;
- for(j=0;j<8;j++)//循环8次,即D1~D8轮流点亮
- {
- P6OUT = ~k;//反相输出,低电平点亮LED
- delay_ms1M(300);//延时
- k=k<<1;//左移一位
- }
- }
- }
复制代码
3编译程序:Project-Build All
4,配置CCS使其产生.hex可执行文件(用Protues仿真时烧录芯片的是.hex文件)
Project->roperties->MSP430 Hex Utility
勾选 Enable MSP430 Hex Utility 再 选到Output Format Options 在Output format栏选择Output TI-TXT hex format (--ti_txt)
7,再次编译程序,将产生.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
下载好后我们以管理员身份运行应用程序。(也可以用常见的MSPFET软件,更好用,64位系统下)
(1),选择串口号(此前还需安装USB转串口驱动 CH340或CH341 链接:https://pan.baidu.com/s/1DvtcWuatTF9EtwSaBLhbog)
进计算机管理系统-设备管理器 -端口查找串口号(必须链接开发板并上电开启)
(2),装载烧录文件。
到工程文件夹中-Debug文件夹找到.txt文件
|