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.

MSP430FR5994: CCS GNU compiler seems to be broken for this MPU

Part Number: MSP430FR5994


Hi Team,

Good day! Could you help to solve and reproduce our customer's concern as shown below.

I'm trying to get some software up and running using CSS with the MSP430FR5994 launchpad. i'm not certain i have the correct part number selected for this support request, but it's the 80 pin "PN" mcu.

I've attached a basic sketch. all you need to reproduce what I have previously done below.

1. grab a stock-standard MSP430FR5994 Launchpad straight out of the box

2. fire up CCS

3.create a new project using "MSP430FR5994" with the GNU toolchain and paste the code into main.c

4. create another new project using "MSP430FR5994" with the TI toolchain and paste the exact same code into main.c

5.run each of them in turn and see the GNU one goes off into lala land and the TI one runs happy as larry, ie: blinking steady at 1hz.

- then try and step through each of them in debug and you'll see the GNU project probably locks at the  "TA0CCR0 += 10000;" line in the ISR (but could go anywhere) and the TI project, again, steps through happy as larry, blinking on or off as it steps past the port toggle.

ok, i hope that's enough information. if both work for you it's possible i have something wrong in my CCS config - if so please let me know what i can do to provide you with further information. actually, i'm so invested, i think i'll keep tinkering with the GNU project and see if i can nail a wrong setting somewhere.

regards, tristen

ps: note there's stuff i added/commented out in an attempt to try and understand what was wrong. this code sample as it stands runs in active mode and needs no modification to demonstrate the issue.

#include <msp430.h>

int g_counter = 0;

int main(void)
{
    WDTCTL = WDTPW | WDTHOLD;               // Stop WDT

    //
    // port initialisation
    //
        P1OUT = 0;
        P1DIR = 0xFF;

        P2OUT = 0;
        P2DIR = 0xFF;

        P3OUT = 0;
        P3DIR = 0xFF;

        P4OUT = 0;
        P4DIR = 0xFF;

        P5OUT = 0;
        P5DIR = 0xFF;

        P6OUT = 0;
        P6DIR = 0xFF;

        P7OUT = 0;
        P7DIR = 0xFF;

        P8DIR = 0xFF;
        P8OUT = 0;

        PJOUT = 0;
        PJDIR = 0xFFFF;

    // Disable the GPIO power-on default high-impedance mode to activate
    // previously configured port settings
    PM5CTL0 &= ~LOCKLPM5;

    // Configure GPIO
    P1DIR |= BIT0;
    P1OUT |= BIT0;

    CSCTL0_H = CSKEY_H;                     // Unlock CS registers
    CSCTL1 = DCOFSEL_6;                     // Set DCO = 8MHz
    CSCTL2 = SELA__VLOCLK | SELS__DCOCLK | SELM__DCOCLK; // Set ACLK = VLO, MCLK = DCO
    CSCTL3 = DIVA__1 | DIVS__8 | DIVM__8;   // Set all dividers
    CSCTL0_H = 0;

    __delay_cycles(1000);

//    for (int i = 0; i <= 10; i++)
//    {
//       P1OUT ^= BIT0;
//
//       __delay_cycles(32000000);
//
//       P1OUT ^= BIT0;
//
//       __delay_cycles(8000000);
//
//       P1OUT ^= BIT0;
//    }

    TA0CCTL0 = CCIE;                        // TACCR0 interrupt enabled
    TA0CCR0 = 10000;
    TA0CTL = TASSEL__ACLK | MC__CONTINOUS; // SMCLK, continuous mode

    __enable_interrupt();

    while (1)
    {
//        LPM3;

        __no_operation();                       // For debugger

//        P1OUT ^= BIT0;
    }
//    __bis_SR_register(LPM0_bits | GIE);     // Enter LPM0 w/ interrupt
//    __no_operation();                       // For debugger
}

// Timer0_A0 interrupt service routine
#if defined(__TI_COMPILER_VERSION__) || defined(__IAR_SYSTEMS_ICC__)
#pragma vector = TIMER0_A0_VECTOR
__interrupt void Timer0_A0_ISR (void)
#elif defined(__GNUC__)
void __attribute__ ((interrupt(TIMER0_A0_VECTOR))) Timer0_A0_ISR (void)
#else
#error Compiler not supported!
#endif
{
    TA0CCR0 += 10000;                       // Add Offset to TA0CCR0

//    __no_operation();                       // For debugger

    P1OUT ^= BIT0;

    g_counter++;

    //__bic_SR_register_on_exit(LPM3_bits);
}

this is the "GNU Compiler" summary of flags set: -mmcu=msp430fr5994 -mhwmult=f5series -I"C:/ti/ccs1040/ccs/ccs_base/msp430/include_gcc" -I"C:/Users/pc-user/workspace_v10/board" -I"C:/ti/ccs1040/ccs/tools/compiler/msp430-gcc-9.3.1.11_win64/msp430-elf/include" -Og -g -gdwarf-3 -gstrict-dwarf -Wall -mlarge -mcode-region=none -mdata-region=lower

and this is the "GNU Linker" summary of flags set: -mhwmult=f5series -Og -g -gdwarf-3 -gstrict-dwarf -Wall -mcode-region=none -mlarge -Wl,-Map,"board.map" -Wl,--gc-sections -L"C:/ti/ccs1040/ccs/ccs_base/msp430/include_gcc" -mmcu=msp430fr5994

Thank you for your support.

Best regards, 

Jonathan

  • - then try and step through each of them in debug and you'll see the GNU project probably locks at the  "TA0CCR0 += 10000;" line in the ISR (but could go anywhere) and the TI project, again, steps through happy as larry, blinking on or off as it steps past the port toggle.

    I can repeat the failure with the posted code, using msp430-gcc-9.3.1.11 and CCS 10.4.0.00006.

    The linker map file shows the Timer0_A0_ISR function has been placed in the .lowtext section, which has been given a run address in RAM (0x1c00) and a load address in FRAM (0x4000):

    .lowtext        0x0000000000001c00       0x10 load address 0x0000000000004000
     .lowtext       0x0000000000001c00       0x10 ./main.o
                    0x0000000000001c00                Timer0_A0_ISR

    The crash occurs because the start-up code isn't copying the .lowtext section from it's load address to run address, and when the Timer0_A0_ISR function the instructions in it's run address in RAM are undefined.

    From a quick search this is the same problem as originally reported in MSP430-GCC-OPENSOURCE: GCC 9.2.0.50 msp430fr5994.ld .lowtext bugfix, and as later reported in MSP430-GCC-OPENSOURCE: GCC 9.3.0.31 .lowtext rule is missing from linker scripts wasn't fixed in a later version of the compiler.

    As suggested in the first referenced thread, changing the msp430fr5994.ld from:

      .lower.text :
      {
        . = ALIGN(2);
        *(.lower.text.* .lower.text)
      } > FRAM

    To:

      .lower.text :
      {
        . = ALIGN(2);
        /* Apply fix as per https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/939422/msp430-gcc-opensource-gcc-9-2-0-50-msp430fr5994-ld-lowtext-bugfix
        *(.lower.text.* .lower.text)
        */
        KEEP (*(.lowtext))
      } > FRAM
    Then allowed the example to run.

    The modified example is attached.

    MSP430FR5994_GNU_ISR.zip

**Attention** This is a public forum