Hi,
I am having problem developing a simple code for the IP Encapsulation. I use MSP430FR5969 Wolverine, MSP-FET430UIF as development kit and board MSP-TS430RGZ48C.
Here is my code:
#include <msp430.h>
#pragma DATA_SECTION (protectedVar, ".ipArea");
#pragma DATA_ALIGN (protectedVar, 1); // reserve one byte for each variable
unsigned char protectedVar[4];
#pragma CODE_SECTION (ipAccess, ".ipAreaC");
void ipAccess()
{
unsigned char c;
c= protectedVar[0];
c = c+1;
protectedVar[1] = c;
}
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
P1DIR |= BIT0; // Configure P1.0 for LED
// Configure MPU
MPUCTL0 = MPUPW | MPUSEGIE | MPUENA; // Write PWD to access MPU registers
MPUIPSEGB1 = 0x0440; // B1 = 0x4400; B2 = 0x4600
MPUIPSEGB2 = 0x0460; // Borders are assigned to IP Encapsulation segments
MPUIPC0 = MPUIPENA | MPUIPLOCK; // IP Encapsulation enabled ;
ipAccess();
protectedVar[0] = 128;
LPM3;
}
// Sys NMI vector
#pragma vector = SYSNMI_VECTOR
__interrupt void SYSNMI_ISR(void)
{
switch(__even_in_range(SYSSNIV,0x18))
{
case 0x00: break;
case 0x02: break;
case 0x04: break;
case 0x06: break;
case 0x08: // MPUSEGPIFG Encapsulated IP Violation
P1OUT=BIT0;
MPUCTL1 &= ~MPUSEG2IFG; // Clear violation interrupt flag
__bic_SR_register_on_exit(LPM3_bits); // Exit LPM3
break;
case 0x0A: break;
case 0x0C: break; // MPUSEG1IFG
case 0x0E: break;
case 0x10: break; // MPUSEG3IFG
case 0x12: break;
case 0x14: break;
case 0x16: break;
case 0x18: break;
default: break;
}
}
Basically, it has to run ipAccess without any problems, since the function is in the protected memory, and should enter in the interrupt (case 0x08) when I try to write 128 inside protectedVar[0]. Actually, it just write and read everything without distinctions and it doesn't enter in the interrupt at all. What am I doing wrong?
Thank you,
Marco