Part Number: MSP430FR2355
I'm trying to invoke the bootloader (BSL) via the falling edge of a 2 millisecond negative pulse applied on the RST~ pin.
The code reconfigures the RST~ pin as NMI. But then when I apply the RST~ pulse, the NMI interrupt handler does not run.
What is missing in the code that would prevent the NMI handler from running?
typedef void (*FuncPtr)(void);
void main(void) {
WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
P1DIR |= 0x03; // Set P1.0, P1.1 to output direction
P1OUT = 0x03; // Turn on the red LED
P6DIR |= (1<<6); // Set P6.6 to output direction (green LED)
P6OUT |= (1<<6); // Turn on the green LED
// NMI interrupt triggers on falling edge of RST~/NMI pin
SFRRPCR |= SYSNMIIES__FALLING;
// Configure RST~/NMI pin as NMI
SFRRPCR |= SYSNMI__NMI_L; // RST~/NMI
for(;;)
{
volatile unsigned int i; // volatile to prevent optimization
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR
P6OUT ^= (1<<6); // Toggle P6.6 using exclusive-OR
i = 100000; // SW Delay
do
{
i--;
} while(i != 0);
}
}
/*****************************************************************************
Function: NMI interrupt service routine
Description:
Dependency: None
*****************************************************************************/
#pragma vector=UNMI_VECTOR
__interrupt void UNMI_ISR(void)
{
volatile unsigned int i;
// Clear all pending user NMI flags
SYSUNIV = 0;
// Enable FRAM program memory writing
SYSCFG0 &= ~PFWP_0;
// Disable global interrupts
__bic_SR_register(GIE);
// Disable NMI interrupt
SFRIE1 &= ~NMIIE__ENABLE;
P1OUT |= 0x01; // Turn on the red LED
P6OUT &= !(1<<6); // Turn off the green LED
for(i=10000; i!=0; i--); // Delay
P1OUT &= !0x01; // Turn off the red LED
P6OUT |= (1<<6); // Turn on the green LED
for(i=100000; i!=0; i--); // Delay
// Invoke the BSL bootloader (never returns)
// Setting the program counter to the memory location 0x1000 starts the BSL.
// The stack is always reset, and RAM is cleared.
// It should be noted that the GIE bit is not disabled, so this should be done by the calling
// application if interrupts are not desired and appropriately returned from "Return to BSL" if they are used.
// Because the stack is reset, the BSL warm start entry point is called as a C function.
FuncPtr fpBsl=(FuncPtr)0x1000;
fpBsl();
}
//***************************************************************************************// MSP430 Blink the LED Demo - Software Toggle P1.0//// Description; Toggle P1.0 by xor'ing P1.0 inside of a software loop.// ACLK = n/a, MCLK = SMCLK = default DCO//// MSP430x5xx// -----------------// /|\| XIN|-// | | |// --|RST XOUT|-// | |// | P1.0|-->LED//// Texas Instruments, Inc// July 2013//***************************************************************************************
#include <msp430fr2355.h>
typedef void (*FuncPtr)(void);
void main(void) { WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer PM5CTL0 &= ~LOCKLPM5; // Disable the GPIO power-on default high-impedance mode // to activate previously configured port settings P1DIR |= 0x03; // Set P1.0, P1.1 to output direction P1OUT = 0x03; // Turn on the red LED P6DIR |= (1<<6); // Set P6.6 to output direction (green LED) P6OUT |= (1<<6); // Turn on the green LED
// NMI interrupt triggers on falling edge of RST~/NMI pin SFRRPCR |= SYSNMIIES__FALLING; // Configure RST~/NMI pin as NMI SFRRPCR |= SYSNMI__NMI_L; // RST~/NMI
for(;;) { volatile unsigned int i; // volatile to prevent optimization
P1OUT ^= 0x01; // Toggle P1.0 using exclusive-OR P6OUT ^= (1<<6); // Toggle P6.6 using exclusive-OR
i = 100000; // SW Delay
do { i--; } while(i != 0); }}
/***************************************************************************** Function: NMI interrupt service routine
Description:
Dependency: None
*****************************************************************************/#pragma vector=UNMI_VECTOR__interrupt void UNMI_ISR(void){ volatile unsigned int i;
// Clear all pending user NMI flags SYSUNIV = 0;
// Enable FRAM program memory writing SYSCFG0 &= ~PFWP_0;
// Disable global interrupts __bic_SR_register(GIE);
// Disable NMI interrupt SFRIE1 &= ~NMIIE__ENABLE;
P1OUT |= 0x01; // Turn on the red LED P6OUT &= !(1<<6); // Turn off the green LED for(i=10000; i!=0; i--); // Delay
P1OUT &= !0x01; // Turn off the red LED P6OUT |= (1<<6); // Turn on the green LED for(i=100000; i!=0; i--); // Delay
// Invoke the BSL bootloader (never returns) // Setting the program counter to the memory location 0x1000 starts the BSL. // The stack is always reset, and RAM is cleared. // It should be noted that the GIE bit is not disabled, so this should be done by the calling // application if interrupts are not desired and appropriately returned from "Return to BSL" if they are used. // Because the stack is reset, the BSL warm start entry point is called as a C function. FuncPtr fpBsl=(FuncPtr)0x1000; fpBsl();}