Hi all,
I'm trying to find why the TI compiler ignores __even_in_range build-in function. I prepared simple example which does not work for me. The version of compiler I use is 4.1.2, I have tested with and without optimization -O3. MCU: MSP430F543A.
#include <msp430.h>
volatile int test = 23;
int main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
return 0;
}
#pragma vector=TIMER0_A1_VECTOR
__interrupt void TIMER0_A1_ISR(void)
{
switch(__even_in_range(TA0IV,14))
{
case 0: test = 234; break;
case 2: test = 42; break;
case 4: test = 75; break; // CCR2 not used
case 6: test = 324; break; // Reserved not used
case 8: test = 23; break; // Reserved not used
case 10: test = 64; break; // Reserved not used
case 12: test = 62; break; // Reserved not used
case 14: test = 12; break; // Overflow not used
default: break;
}
}
For switch statement the compiler produces unoptimized code like this:
PUSHM.A #1,R15
MOV.W &Timer0_A5_TA0IV,R15
TST.W R15
JEQ ($C$L7)
DECD.W R15
JEQ ($C$L6)
DECD.W R15
JEQ ($C$L5)
DECD.W R15
JEQ ($C$L4)
DECD.W R15
JEQ ($C$L3)
...
How can I turn on this optimization ? Am I doing something wrong in source code? Does __even_in_range work in non-ISR functions with ordinary variables (other than xxxIV flags) ?
Thanks for help,
Matthew