Other Parts Discussed in Thread: MSP430FR5994, MSP430FR2476, MSP430FR2676, MSP430FR50431, MSP430FR5043, MSP430FR5962, MSP430FR5964, MSP430FR5992, MSP430FR59941, MSP430FR6005, MSP430FR6007, MSP430FR6035, MSP430FR60371, MSP430FR6037, MSP430FR60431, MSP430FR6043, MSP430FR6045, MSP430FR60471, MSP430FR6047
Hi,
this minimal example compiled for MSP430FR5994 using MSP430 GCC 9.2.0.50 (both on CCS Cloud and on our computer)
fails to blink the LED.
#include <msp430.h> int main(void) { WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer P1DIR |= BIT0; PM5CTL0 &= ~LOCKLPM5; TA4CTL = MC__STOP | TACLR; TA4CCR0 = 31250; // 4 times per second TA4CCTL0 = CCIE; // TA4CCR0 interrupt enabled TA4CTL = TASSEL__SMCLK | ID__8 | MC__UP; // SMCLK/8, UP mode __enable_interrupt(); do {} while(1); return 0; } void __interrupt_vec(TIMER4_A0_VECTOR) Timer4_A0_ISR (void) { P1OUT ^= BIT0; }
After comparison with other linker scripts in include/ directory, the default linker script msp430fr5994.ld is believed to be the cause,
as the interrupt routine is placed in ".lowtext" section that then goes somewhere in RAM, but is expected to be in FRAM.
Proposed fix seems to place the ".lowtext" in correct memory section.
--- msp430-gcc-9.2.0.50/include/msp430fr5994.ld +++ fixed_msp430fr5994.ld @@ -415,29 +415,29 @@ .lower.text : { . = ALIGN(2); *(.lower.text.* .lower.text) } > FRAM .text : { PROVIDE (_start = .); . = ALIGN(2); KEEP (*(SORT(.crt_*))) . = ALIGN(2); - *(.lower.text.* .lower.text) + KEEP (*(.lowtext)) . = ALIGN(2); *(.text .stub .text.* .gnu.linkonce.t.* .text:*) /* See the note in .rodata section about why we do not have this line here: *(.either.text.* .either.text) */ KEEP (*(.text.*personality*)) /* .gnu.warning sections are handled specially by elf32.em. */ *(.gnu.warning) *(.interp .hash .dynsym .dynstr .gnu.version*) PROVIDE (__etext = .);
Any feedback on this?
Best regards
Petr