Part Number:MSP430F5418A
Tool/software: Code Composer Studio
Hi,
I've recently upgraded CCS from 7.X up to 8.1.0 and enabled the vacant memory access interrupt for the first time. After doing so I came accross very regular and strange SYSNMI_VECTOR interrupts every time a function executed that did an instruction fetch from address 0x25BFF.
On each compilation and attempt to debug the issue it kept moving as the function placed at the end location changed. Many red herring and dead end paths taken to come to this conclusion.
An exert from my .cmd file now reads;
MEMORY
{
SFR : origin = 0x0000, length = 0x0010
PERIPHERALS_8BIT : origin = 0x0010, length = 0x00F0
PERIPHERALS_16BIT : origin = 0x0100, length = 0x0100
BSL0 : origin = 0x1000, length = 0x0200
BSL1 : origin = 0x1200, length = 0x0200
BSL2 : origin = 0x1400, length = 0x0200
BSL3 : origin = 0x1600, length = 0x01F0
/* This will nuke the BSL entirely and NOT let it startup.
* Upon next erasure cycle of the BSL3 area this will be set
* to 0xFFFF which is an acceptable value. it must be 0xFFFF
* or 0x0000. If this is NOT the case, then the device becomes
* inoperable. And that would be bad :)
*
* Side note; this also ensures that the BSL is never accidentially
* entered.
*/
BSLZ : origin = 0x17F0, length = 0x0010, fill = 0x0000
INFOD : origin = 0x1800, length = 0x0080
INFOC : origin = 0x1880, length = 0x0080
INFOB : origin = 0x1900, length = 0x0080
INFOA : origin = 0x1980, length = 0x0080
//RAMZ : origin = 0x1C00, length = 0x0100, fill=0xA0A0
RAM : origin = 0x1C00, length = 0x4000
FLASH : origin = 0x5C00, length = 0xA380 , fill = 0x3FFF
FLASH2 : origin = 0x10000,length = 0x15B80, fill = 0x3FFF
//Keep these bytes empty. Had VMAI errors raised in last section
FLASH3 : origin = 0x25B80,length = 0x80 , fill = 0x3FFF
....
SECTIONS
{
.TI.noinit : {} > RAM /* For #pragma noinit */
.bss : {} > RAM /* Global & static vars */
.data : {} > RAM /* Global & static vars */
.cio : {} > RAM /* C I/O Buffer */
.dbg : {} > RAM
.sysmem : {} > RAM /* Dynamic memory allocation area */
/******************************** MEMORY HOLE ********************************/
.stack : {} > RAM (HIGH) /* Software system stack */
#ifndef __LARGE_CODE_MODEL__
.text : {} > FLASH /* Code */
#else
.text : {} >> FLASH2 | FLASH /* Code */
#endif
.text:_isr : {} > FLASH /* ISR Code space */
.cinit : {} > FLASH /* Initialization tables */
#ifndef __LARGE_DATA_MODEL__
.const : {} > FLASH /* Constant data */
#else
.const : {} >> FLASH | FLASH2 /* Constant data */
#endif
.pinit : {} > FLASH /* C++ Constructor tables */
.binit : {} > FLASH /* Boot-time Initialization tables */
.init_array : {} > FLASH /* C++ Constructor tables */
.mspabi.exidx : {} > FLASH /* C++ Constructor tables */
.mspabi.extab : {} > FLASH /* C++ Constructor tables */
#ifdef __TI_COMPILER_VERSION__
#if __TI_COMPILER_VERSION__ >= 15009000
#ifndef __LARGE_CODE_MODEL__
.TI.ramfunc : {} load=FLASH, run=RAM, table(BINIT)
#else
.TI.ramfunc : {} load=FLASH | FLASH2, run=RAM, table(BINIT)
#endif
#endif
#endif
.bsl0.noinit : {} > BSL0, type=NOLOAD
.bsl1.noinit : {} > BSL1, type=NOLOAD
.bsl2.noinit : {} > BSL2, type=NOLOAD
.bsl3.noinit : {} > BSL3, type=NOLOAD
/* Nerf the BSLZ zone leaving the BSL disabled and JTAG access
* enabled for development/release
*/
.bslz : {} > BSLZ, fill=0x0000
.infoA : {} > INFOA /* MSP430 INFO FLASH Memory segments */
.infoB : {} > INFOB
.infoC : {} > INFOC
.infoD : {} > INFOD
I'm filling all unused flash with 0x3FFF to ensure a proper code jump in case of onerous execution. The function that was being placed into the very last few bytes were
Proof _outc is at end of address range;
0x025BE2 _outc
0x025BE2 9D9D 0002 0004 2C07 4D2E 0ECF 531F
0x025BF0 4F8D 0000 4CCE 0000
0x025BF8 $C$L6
0x025BF8 539D 0004 4C4C 0110
Use linker directive;
MEMORY
{
...
FLASH3 : origin = 0x25B80,length = 0x80 , fill = 0x3FFF
...
}
SECTIONS { ... .VMI.endFlash : { --library=rts430x_lc_sd_eabi.lib<snprintf.c.obj>(.text:_outc) } > FLASH3 (HIGH) ... }
Set breakpoint after program address 0x25BEE to be able to step through the code during run-time.
execute this code on startup;
/* Enable the FLASH and Memory access interrupts
*/
SFR_clearInterrupt(SFR_VACANT_MEMORY_ACCESS_INTERRUPT |
SFR_FLASH_CONTROLLER_ACCESS_VIOLATION_INTERRUPT);
SFR_enableInterrupt(SFR_VACANT_MEMORY_ACCESS_INTERRUPT |
SFR_FLASH_CONTROLLER_ACCESS_VIOLATION_INTERRUPT);
Pre & Post interrupt core registers
![]()
![]()
If I run the same hex file on a MSP430F5437A I do not get the same interrupt. I assume this is because the next flash address of 0x25C00 is valid and some kind of pre-fetch operation is occurring without checking for flash boundary limits.
If any instruction fetch operation occurs in the last 0x08 bytes of FLASH then a VMA Interrupt occurs. (I've tested 0x10 to 0x01 buffer zone from end of flash)
This will fail; Less than 8 bytes
//Keep these bytes empty. Had VMAI errors raised in last section
FLASH3 : origin = 0x25B00,length = 0xFA , fill = 0x3FFF
FLASH4 : origin = 0x25BFA,length = 0x06 , fill = 0x3FFF
This is OK; Equal or greater than 8 bytes
//Keep these bytes empty. Had VMAI errors raised in last section
FLASH3 : origin = 0x25B00,length = 0xF8 , fill = 0x3FFF
FLASH4 : origin = 0x25BF8,length = 0x08 , fill = 0x3FFF
(Please visit the site to view this file)
My working linker file for the MSP430F5418a project
This is my linker line for all my build options and inclusions.
"C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.2.LTS/bin/cl430" -vmspx
--data_model=small -O0
--opt_for_speed=1
--align_for_power
--use_hw_mpy=F5
--define=__MSP430F5418A__
--c99
--float_operations_allowed=all
--printf_support=full
--gen_data_subsections=on
--silicon_errata=CPU21
--silicon_errata=CPU22
--silicon_errata=CPU23
--silicon_errata=CPU40 -z
--heap_size=160
--stack_size=2048
--cinit_hold_wdt=on -i"C:/ti/ccsv8/ccs_base/msp430/include"
-i"C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.2.LTS/lib"
-i"C:/ti/ccsv8/tools/compiler/ti-cgt-msp430_18.1.2.LTS/include"
-i"C:/ti/ccsv8/ccs_base/msp430/lib/5xx_6xx_FRxx"
-i"C:/ti/msp/MSP430Ware_3_80_04_05/iqmathlib/libraries/CCS/MPY32/5xx_6xx"
--reread_libs
--warn_sections
--xml_link_info="MAT3_linkInfo.xml"
--rom_model -o "MAT3.out" ## <obj list removed> ## "../lnk_msp430f5418a.cmd" -llibc.a -llibmath.a -lIQmathLib.a -lIQmathLib_CCS_MPY32_5xx_6xx_CPUX_large_code_small_data.lib