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.

MSP430FR5962: MPU flags are unable to clear

Part Number: MSP430FR5962

Hi experts,

Can anyone please check the below code and say me why MPU is not able to clear the segment 2 flag. When I'm trying to clear the segment 2 flag my device is getting reset. I have also mentioned as a comment where the device is resetting. Please find the code below:

#include <MSP430FR5962.h>

unsigned int *ptr = 0;
unsigned int Data =0;

int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT

// Configure GPIO
P1DIR |= BIT0; // Configure P1.0 for LED

// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;

while (MPUCTL1 & MPUSEG2IFG) // has reset occurred due to Seg2
{
P1OUT ^= BIT0; // Toggle LED
__delay_cycles(30000); // Delay to see toggle

/* it is getting reset after the violation when it is trying to execute the below statements*/
MPUCTL0 &= ~MPUENA;
MPUCTL1 &= ~MPUSEG2IFG;
}

// Configure MPU
MPUCTL0 = MPUPW; // Write PWD to access MPU registers
MPUSEGB1 = 0x0F00; // B1 = 0x6000; B2 = 0x8000
MPUSEGB2 = 0x0FF7; // Borders are assigned to segments

// Segment 1 - Execute, Read
// Segment 2 - Violation, Execute, Read
// Segment 3 - Execute, Read
MPUSAM = MPUSEG1RE | MPUSEG1XE | MPUSEG1WE |
MPUSEG2VS | MPUSEG2RE | MPUSEG2XE |
MPUSEG3RE | MPUSEG3XE | MPUSEG3WE |
MPUSEGIRE | MPUSEGIXE | MPUSEGIWE;
MPUCTL0 = MPUPW | MPUENA | MPUSEGIE;

Data = 0x88;

// Cause an MPU violation by writing to segment 2
ptr = (unsigned int *)0xF002;
*ptr = Data;

while(1); // Code never gets here
}

**Attention** This is a public forum