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.

MSP430FR6989: Issue Writing to FRAM Upon Button Press Using driverlib

Part Number: MSP430FR6989

Hello, I'm working on a program in which a push-button press will write a value stored in the variable 'data' to FRAM using the driverlib function FRAM_memoryFill32. I've been debugging with a watch window open to track the variables 'press' and 'data'. Upon the first button press, the interrupt is enabled and the first value of 'data' is written to memory. However, upon subsequent button presses, the value stored in 'data' is no longer rewritten, and is reset back to zero. 'press' is also reset back to zero. Here is my code:

#include "driverlib.h"
#include "msp430.h"
#include "intrinsics.h"
#include "stdio.h"

#define FRAM_TEST_START 0x4800                          // Define initial location in FRAM as address 0x4800
unsigned int press = 0;                                 // Initialize variable 'press' 

uint32_t data = 0;                                       // initialize 32-bit 'data' variable


int main(void) {                                       
  
  WDT_A_hold(WDT_A_BASE);                               // Stop Watchdog Timer
  PMM_unlockLPM5(PMM_BASE);                             // Unlock pins
  
  GPIO_setAsInputPin(GPIO_PORT_P1, GPIO_PIN1);          // Set P1.1 as input
  GPIO_setAsInputPinWithPullUpresistor(GPIO_PORT_P1, GPIO_PIN1); // Set P1.1 pull-up resistor
  GPIO_interruptEdgeSelect(GPIO_PORT_P1, GPIO_PIN1, 
                           GPIO_HIGH_TO_LOW_TRANSITION);
  
  GPIO_enableInterrupt(GPIO_PORT_P1, GPIO_PIN1);        // Enable interrupts on P1.1
  GPIO_clearInterruptFlag(GPIO_PORT_P1, GPIO_PIN1);     // Clear interrupt flag on P1.1
  
  GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0);         // Set P1.0 as output
  GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0);      // Initialize P1.0 as low 
  GPIO_setAsOutputPin(GPIO_PORT_P9, GPIO_PIN7);         // Set P9.7 as output
  GPIO_setOutputHighOnPin(GPIO_PORT_P9, GPIO_PIN7);     // Initialize P9.7 as high
 
  
  FRAM_memoryFill32(FRAM_BASE,data,(uint32_t*)FRAM_TEST_START,128);

  //Enter LPM3
  __bis_SR_register(LPM0_bits+GIE); // Enter LPM0
  
  //__no_operation(); 
  
  

}

// ISR for pushbutton P1.1
#pragma vector=PORT1_VECTOR
__interrupt void Port_1(void)
{
    // debouncing
   __delay_cycles(64000);                         // Wait 64000 cycles
   if ((P1IN & BIT1) != BIT1) {
      press += 1;                                    // Increment pushbutton count
  
      if (press < 10 & press > 0) {
      data += 0x00010001;        
      }
  
      else  {
      press = 0;
      data = 0x00000000;
      }
   }
   
  
   GPIO_toggleOutputOnPin(GPIO_PORT_P1, GPIO_PIN0);    // Toggle both output LEDs
   GPIO_toggleOutputOnPin(GPIO_PORT_P9, GPIO_PIN7);
   
   FRAM_memoryFill32(FRAM_BASE,data,(uint32_t*)FRAM_TEST_START,128);
   
   GPIO_clearInterruptFlag(GPIO_PORT_P1, GPIO_PIN1); // Clear interrupt flag on P1.1
   
   
}

**Attention** This is a public forum