Part Number: MSP430FR5994
Other Parts Discussed in Thread: 4428
Tool/software: TI C/C++ Compiler
I took the following example in
MSP430 Optimizing C/C++ Compiler v17.3.0.STS, User's Guide, SLAU132O 2017-03
6.8.4.1 Using __never_executed With a Vector Generator, page 138
Example 6-8. TBIV Vector Generator
int state;
#pragma RETAIN(Timer_B1)
__interrupt void Timer_B1 (void) __attribute__((__section__(".text:_isr")));
void Timer_B1 (void)
{
switch(TB0IV)
{
case 0:
break; /* Do nothing */
case 2:
TBCCR1 += 255;
state +=1;
break;
case 4:
TBCCR0 = 254;
TBCCR1 = 159;
state =200;
break;
case 6:
break;
case 8:
break;
case 10:
break;
case 12:
break;
case 14:
break;
default:
__never_executed();
}
}
I compiled this example in the two configurations:
- Debug, --opt_level=0 --opt_for_speed=0
- Release, --opt_level=4 --opt_for_speed=5
With the compiler: TI v16.9.4.LTS
Unlike what is written in the documentation, there is no switch table generated.
"... for this example, the compiler will generate a switch table where the value of TBIV is simply added to the PC to jump to the appropriate code block ..."
The generated code is really inefficient for an interrupt service routine.
Details:
* Configuration Debug, --opt_level=0, --opt_for_speed=0
* Compiler version: TI v16.9.4.LTS
* Compiler options: -vmspx --data_model=restricted --opt_for_speed=0 --use_hw_mpy=F5 --include_path="C:/ti/ccsv7/ccs_base/msp430/include" --include_path="D:/sontex/dev/Produit/Integr/731/4_FW/ESSAIS_JMM/intrinsic_never_executed" --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-msp430_16.9.4.LTS/include" --advice:power=all --advice:hw_config=all --define=__MSP430FR5994__ --define=_MPU_ENABLE -g --printf_support=minimal --preproc_with_comment --preproc_with_compile --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40
* Linker options: -vmspx --data_model=restricted --opt_for_speed=0 --use_hw_mpy=F5 --advice:power=all --advice:hw_config=all --define=__MSP430FR5994__ --define=_MPU_ENABLE -g --printf_support=minimal --preproc_with_comment --preproc_with_compile --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 -z -m"intrinsic_never_executed.map" --heap_size=160 --stack_size=160 --cinit_hold_wdt=on -i"C:/ti/ccsv7/ccs_base/msp430/include" -i"C:/ti/ccsv7/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccsv7/ccs_base/msp430/lib/FR59xx" -i"C:/ti/ccsv7/tools/compiler/ti-cgt-msp430_16.9.4.LTS/lib" -i"C:/ti/ccsv7/tools/compiler/ti-cgt-msp430_16.9.4.LTS/include" --priority --reread_libs --define=_MPU_ENABLE --diag_wrap=off --display_error_number --warn_sections --xml_link_info="intrinsic_never_executed_linkInfo.xml" --use_hw_mpy=F5 --rom_model
* Desassembled code:
TEXT Section .text:_isr, 0x5C bytes at 0x4000
004000: Timer_B1:
004000: .text:_isr:Timer_B1:
004000: .text:_isr:
004000: 0F14 PUSHM.A #1,R15
004002: 1F42 MOV.W &TB0IV_L,R15
004004: EE03
004006: 0F93 TST.W R15
004008: 1424 JEQ ($C$L3)
00400a: 2F83 DECD.W R15
00400c: 0D24 JEQ ($C$L2)
00400e: 2F83 DECD.W R15
004010: 0124 JEQ ($C$L1)
004012: 0F3C JMP ($C$L3)
004014: $C$L1:
004014: B240 MOV.W #0x00fe,&TB0CCR0_L
004016: FE00
004018: D203
00401a: B240 MOV.W #0x009f,&TB0CCR1_L
00401c: 9F00
00401e: D403
004020: B240 MOV.W #0x00c8,&state
004022: C800
004024: 001C
004026: 053C JMP ($C$L3)
004028: $C$L2:
004028: B250 ADD.W #0x00ff,&TB0CCR1_L
00402a: FF00
00402c: D403
00402e: 9253 INC.W &state
004030: 001C
004032: $C$L3:
004032: 0F16 POPM.A #1,R15
004034: 0013 RETI
*
* Configuration Release, --opt_level=4, --opt_for_speed=5
* Compiler version: TI v16.9.4.LTS
* Compiler options: -vmspx --data_model=restricted -O4 --opt_for_speed=5 --use_hw_mpy=F5 --include_path="C:/ti/ccsv7/ccs_base/msp430/include" --include_path="D:/sontex/dev/Produit/Integr/731/4_FW/ESSAIS_JMM/intrinsic_never_executed" --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-msp430_16.9.4.LTS/include" --advice:power=all --advice:hw_config=all --define=__MSP430FR5994__ --define=_MPU_ENABLE --printf_support=minimal --preproc_with_comment --preproc_with_compile --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40
* Linker options: -vmspx --data_model=restricted -O4 --opt_for_speed=5 --use_hw_mpy=F5 --advice:power=all --advice:hw_config=all --define=__MSP430FR5994__ --define=_MPU_ENABLE --printf_support=minimal --preproc_with_comment --preproc_with_compile --diag_warning=225 --diag_wrap=off --display_error_number --silicon_errata=CPU21 --silicon_errata=CPU22 --silicon_errata=CPU40 -z -m"intrinsic_never_executed.map" --heap_size=160 --stack_size=160 --cinit_hold_wdt=on -i"C:/ti/ccsv7/ccs_base/msp430/include" -i"C:/ti/ccsv7/ccs_base/msp430/lib/5xx_6xx_FRxx" -i"C:/ti/ccsv7/ccs_base/msp430/lib/FR59xx" -i"C:/ti/ccsv7/tools/compiler/ti-cgt-msp430_16.9.4.LTS/lib" -i"C:/ti/ccsv7/tools/compiler/ti-cgt-msp430_16.9.4.LTS/include" --priority --reread_libs --define=_MPU_ENABLE --diag_wrap=off --display_error_number --warn_sections --xml_link_info="intrinsic_never_executed_linkInfo.xml" --use_hw_mpy=F5 --rom_model
* Desassembled code:
TEXT Section .text:_isr, 0x5A bytes at 0x4000
004000: Timer_B1:
004000: [0].text:_isr:Timer_B1:
004000: .text:_isr:
004000: 0F14 PUSHM.A #1,R15
004002: 1F42 MOV.W &TB0IV_L,R15
004004: EE03
004006: 0F93 TST.W R15
004008: 1324 JEQ ($C$L19)
00400a: 2F83 DECD.W R15
00400c: 0C24 JEQ ($C$L18)
00400e: 2F83 DECD.W R15
004010: 0F20 JNE ($C$L19)
004012: B240 MOV.W #0x00fe,&TB0CCR0_L
004014: FE00
004016: D203
004018: B240 MOV.W #0x009f,&TB0CCR1_L
00401a: 9F00
00401c: D403
00401e: B240 MOV.W #0x00c8,&state
004020: C800
004022: 001C
004024: 053C JMP ($C$L19)
004026: $C$L18:
004026: B250 ADD.W #0x00ff,&TB0CCR1_L
004028: FF00
00402a: D403
00402c: 9253 INC.W &state
00402e: 001C
004030: $C$L19:
004030: 0F16 POPM.A #1,R15
004032: 0013 RETI