This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler/MSP430FR5989: MSP430 compiler ignores __even_in_range for large code memory model

Part Number: MSP430FR5989


Tool/software: TI C/C++ Compiler

Hello,

In UART ISR I'm using the following code:

switch (__even_in_range(iv, USCI_UART_UCTXCPTIFG)) {
	case USCI_NONE:
		break;
	case USCI_UART_UCRXIFG:
		//code
		break;
	case USCI_UART_UCTXIFG:
		//code
		break;
	case USCI_UART_UCSTTIFG:
		break;
	case USCI_UART_UCTXCPTIFG:
		//code			
		break;
	default:
		__never_executed();
		break;
}

If I compile this code with small code memory model option then I get in the result optimized version, similar to:

005cb6: 5210 036E ADD.W &USCI_UART_UCTXCPTIFG,PC
005cba: 3C23 JMP ($C$L9)
005cbc: 3C1E JMP ($C$L8)
(...)

If I use the large code memory model then I get "normal" switch version:

MOV.W &USCI_UART_UCTXCPTIFG,R15
TST.W R15
JEQ ($C$L7)
DECD.W R15
JEQ ($C$L6)
DECD.W R15
JEQ ($C$L5)
DECD.W R15
(...)

Is it possible to force compiler to use optimized version?

I found the similar thread is in MSP Low-Power Microcontroller Forum but there is no answer.

Best regards,

Mateusz

PS. I apologize in advance for possible language errors.

  • Mateusz Gzella said:
    If I use the large code memory model then I get "normal" switch version:

    Unfortunately, I am unable to reproduce that result.  Please follow these steps to submit a test case.

    1. Preprocess the source file with the problem switch statement
    2. Attach that to your next post
    3. Indicate the version of the compiler (not CCS) used
    4. Show all the build options exactly as the compiler sees them

    Thanks and regards,

    -George

  • I created an empty project for MSP430FR5989 and put in main following code:

    #include <msp430.h> 
    #include <stdint.h>
    static volatile struct {
    	uint16_t txCnt;
    	uint16_t rxCnt;
    	uint16_t txCompletedCnt;
    } gUart;
    
    #if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
    #pragma vector=USCI_A1_VECTOR
    __interrupt void USCI_A1_ISR(void)
    #elif defined(__GNUC__)
    void __attribute__ ((interrupt(USCI_A1_VECTOR))) USCI_A1_ISR (void)
    #else
    #error Compiler not supported!
    #endif
    {
    //	uint16_t iv;
    //	iv = UCA1IV;
    //	switch (__even_in_range(iv, USCI_UART_UCTXCPTIFG)) {
    	switch (__even_in_range(UCA1IV, USCI_UART_UCTXCPTIFG)) {
    	case USCI_NONE:
    		break;
    	case USCI_UART_UCRXIFG:
    		++gUart.rxCnt;
    		break;
    	case USCI_UART_UCTXIFG:
    		++gUart.txCnt;
    		break;
    	case USCI_UART_UCSTTIFG:
    		break;
    	case USCI_UART_UCTXCPTIFG:
    		++gUart.txCompletedCnt;
    		break;
    	default:
    		__never_executed();
    		break;
    	}
    }
    
    int main(void) {
        WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer
    	
    	return 0;
    }
    
    
    

    Compiler version 16.9.2.LTS, build command:

    "C:/ti/ccsv7/tools/compiler/ti-cgt-msp430_16.9.2.LTS/bin/cl430" -vmspx --data_model=restricted -O4 --opt_for_speed=4 --use_hw_mpy=F5 --include_path="C:/ti/ccsv7/ccs_base/msp430/include" --include_path="C:/TI_workspace/bug" --include_path="C:/ti/ccsv7/tools/compiler/ti-cgt-msp430_16.9.2.LTS/include" --advice:power=all --advice:hw_config="all" --define=__MSP430FR5989__ --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  "../main.c"

    6661.main.pp.txt

  • Thank you for submitting a test case.  I can reproduce the same result.  I filed CODEGEN-2213 in the SDOWP system to have this addressed.  This entry does not report a defect in the compiler, but requests that the output of the compiler be improved.  You are welcome to follow it with the SDOWP link below in my signature.

    Thanks and regards,

    -George