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 标志无法清除

Guru**** 2439710 points


请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/microcontrollers/msp-low-power-microcontrollers-group/msp430/f/msp-low-power-microcontroller-forum/1032608/msp430fr5962-mpu-flags-are-unable-to-clear

器件型号:MSP430FR5962

各位专家、您好!

能不能有人检查下面的代码并告诉我为什么 MPU 不能清除段2标志。 当我尝试清除段2标志时、我的器件将被复位。 我还在评论中提到了器件复位的位置。 请查找以下代码:

#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
}

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    我认为您需要  

    >MPUCTL0 = MPUPW;  

    在清零 MPUSEG2IFG 位之前(我没有看到 MPUCTL1的异常)。

    我怀疑您也可以通过读取 SYSRSTIV 来清除 IFG (不带密码)。