Hello
I want to use the FRAM to store some persist variables for my aplication. Those are calibration variables, so it's mandatory that they are write/read.
I followed the example "msp430fr267x_framwrite_persistent.c" from CCS/resource explorer/MSPware and it works perfectly fine, but i don't know in which position those variables are stored on FRAM
#include <msp430.h>
// Statically-initialized variable
#ifdef __TI_COMPILER_VERSION__
#pragma PERSISTENT(Port_event)
unsigned long Port_event = 0;
#elif __IAR_SYSTEMS_ICC__
__persistent unsigned long Port_event = 0;
#else
// Port the following variable to an equivalent persistent functionality for the specific compiler being used
unsigned long Port_event = 0;
#endif
void initGpio(void);
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// Configure GPIO
initGpio();
// Determine whether we are coming out of an LPMx.5 or a regular RESET.
if (SYSRSTIV == SYSRSTIV_LPM5WU) // MSP430 just woke up from LPMx.5
{
// Add the variable Port_event in FRAM to record the button event
// Write protection starts from the beginning of Program FRAM + 1024 bytes
// Code start address + 1024 bytes, Linker command file should be modified
SYSCFG0 = FRWPPW | FRWPOA0 | DFWP | PFWP;// Configure 1024 bytes for FRAM write
Port_event++; // Record the port event in FRAM
SYSCFG0 = FRWPPW | DFWP | PFWP; // Program FRAM write protected (not writable)
do
{
P1OUT |= BIT0; // P1.0 = toggle
__delay_cycles(100000);
P1OUT &= ~BIT0; // P1.0 = toggle
__delay_cycles(100000);
}while (Port_event >= 5); // Recorded 5 port interrupts?
}
// Device powered up from a cold start.
// It configures the device and puts the device into LPM4.5
P1DIR &= ~(BIT2); // Configure P1.2 as input direction pin
P1OUT |= BIT2; // Configure P1.2 as pulled-up
P1REN |= BIT2; // P1.2 pull-up register enable
P1IES |= BIT2; // P1.2 Hi/Low edge
P1IFG = 0; // Clear all P1 interrupt flags
P1IE |= BIT2; // P1.2 interrupt enabled
// Explicitly clear RTC control registers to disable it
// just incase if the RTC was previously enabled
RTCCTL = 0;
PMMCTL0_H = PMMPW_H; // Open PMM Registers for write
PMMCTL0_L |= PMMREGOFF; // and set PMMREGOFF
PMMCTL0_H = 0; // Lock PMM Registers
// Enter LPM4 Note that this operation does not return. The LPM4.5
// will exit through a RESET event, resulting in a re-start
// of the code.
__bis_SR_register(LPM4_bits | GIE);
}
-- pragma PERSISTENT
#pragma PERSISTENT(Port_event)
unsigned long Port_event = 0;
-- write variable
// Add the variable Port_event in FRAM to record the button event
// Write protection starts from the beginning of Program FRAM + 1024 bytes
// Code start address + 1024 bytes, Linker command file should be modified
SYSCFG0 = FRWPPW | FRWPOA0 | DFWP | PFWP;// Configure 1024 bytes for FRAM write
Port_event++; // Record the port event in FRAM
SYSCFG0 = FRWPPW | DFWP | PFWP; // Program FRAM write protected (not writable)
On the example's description, it mentions that "Linker command file should be modified to change memory partitioning and specify the location of PERSISTENT variables"
Could you give some and example on how to "place" the PERSISTENT variables in different memory locations?
Looking at the Application report SLAA628b, the example 3 (for CCS) shows how to allocate a new memory block + define a segment that store in this memory block.
1. Allocate a new memory block(MY_SECTION).
2. Define a segment(.Image) that store in this memory block(MY_SECTION).
3. Use #pragma DATA_SECTION in program to define variables in this segment.
RAM : origin = 0x2000, length = 0x400
RAM2 : origin = 0xF100, length = 0x100
MY_SECTION : origin = 0xF200, length = 0x100
FRAM : origin = 0xF300, length = 0xC80
.Image : {} > MY_SECTION
#pragma DATA_SECTION(a,".Image") unsigned char a;
The issue is that I'm not able to write variables on this new memory block using the method "--write variable" from the first example.
Should i declare this new memory block inside the FRAM section? if that’s the case, could you point me out how to do so?
Also, I don't know if it's a good practice to create a new memory block instead of using the already declared PERSISTENT
Best regards




