Generate .bin .hex .txt files on CCS and burn them to MSP430 to make the LCD light up
[Copy link]
1. Create the project file correctly on CCS.
New Project: File-New-CCS Project
2. Write the program in the main.c file and save it.
1 #include <msp430f169.h>
2 /*
3 * Software delay
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;//Turn off watchdog
16 P6DIR = 0xff;//Set P4 port as output port
17 while(1)
18 {
19 k = 1;
20 for(j=0;j<8;j++)//Loop 8 times, i.e. D1~D8 light up in turn
21 {
22 P6OUT = ~k;//Inverted output, low level lights up LED
23 delay_ms1M(300);//Delay
24 k=k<<1;//Left shift
25 }
26 }
27
28 }
3 Compile the program: Project-Build All
4. Configure CCS to generate a .hex executable file (the chip downloaded when simulating with Protues is a .hex file)
Project-Properties-MSP430 Hex Utility
Check Enable MSP430 Hex Utility and then Apply and Close
5. Compile the program again and a .hex file will be generated.
result:
**** 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. Configure CCS again and convert the .hex file into a .txt file. The specific steps are as follows:
a. Click Project and select Properties.
b. Select Build - Steps
c. Add the following statement in Post-build steps, apply and close:
"${CG_TOOL_HEX}" --ti_txt "${BuildArtifactFileName}" -o "${BuildArtifactFileBaseName}.txt" -order MS -romwidth 16
7. Compile the program again and a .txt file will be generated (the compilation may be invalid, go in and check the configuration, and then compile. You can also go to the project folder to see if a .txt file is generated)
result:
**** 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 ****
|