Part Number: MSP430FR5969
Tool/software: TI C/C++ Compiler
This post is a follow up on the related question with new information. All previously described behavior is still occurring, but I found that the source of the wild program counter is a bad value stored in SYSRSTIV located at 0xFFFE. The address stored at this location is loaded into the program counter right before the user program is started:
Using GDB we can see the difference between normal and erroneous operation:
Normal Operation
(gdb) layout asm (gdb) x/8i 0xfffa 0xfffa: interrupt service routine at 0xffff 0xfffc: interrupt service routine at 0xffff 0xfffe: interrupt service routine at 0xdcb4 0x10000 <last_rst>: beq 0x10002 <mpu_rsts>: beq 0x10004 <wdt_rsts>: beq 0x10006 <rsts>: beq 0x10008: and.b @r15+, -1(r15) ; 0xffff
Erroneous Operation
(gdb) layout asm (gdb) x/8i 0xfffa 0xfffa: interrupt service routine at 0xffff 0xfffc: interrupt service routine at 0xffff 0xfffe: interrupt service routine at 0xffff 0x10000 <last_rst>: beq 0x10002 <mpu_rsts>: beq 0x10004 <wdt_rsts>: beq 0x10006 <rsts>: beq 0x10008: and.b @r15+, -1(r15) ; 0xffff
The code snippets show the location of interest (RESETVEC) and the surrounding instructions. Prior to running, 0xFFFE always appears to be correct when I print the memory location. It's only after attempting to run the program and it getting lost in garbage land that I can see it's 0xFFFF instead of the correct value 0xDCB4. I'm not sure if this is GDB reporting the wrong/old value or if it somehow gets clobbered. It's suspicious that it only happens on the first launch and never any subsequent loads.
I looked through the msp430-gcc source code but couldn't find anything useful in crt0_start.S or anywhere else. I would appreciate any info on how the $pc gets loaded, how 0xFFFE is set, or what might be going wrong.