Hi TI Team,
The MSP430FR2311PW20 got the FRAM, right?
Looking for any sample code to read/write from/to FRAM .
Regards,
Walter
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.
Hi TI Team,
The MSP430FR2311PW20 got the FRAM, right?
Looking for any sample code to read/write from/to FRAM .
Regards,
Walter
Hello Walter,
Here are some example projects for FR2311 device and there are couple for FRAM write.
http://dev.ti.com/tirex/explore/node?node=ANl1oYi0.klyjvtEKGoMlA__IOGqZri__LATEST&search=MSP430FR2311
Thanks,
Yiding
Thanks Yiding,
What is the FRAM memory for information data purpose only? Or, no difference?
The memory map of the MSP430FR231x MCUs only shows the range:
FFFFh to FF80h
FFFFh to F100h
Regards,
Walter
Hi Yiding,
Writing is set during run time and can read the value.
After reboot, I read value but the value not retained
#define FRAM_TEST_START 0xFD00
unsigned int *pointer;
unsigned int data;void main(){ pointer = (unsigned int *)FRAM_TEST_START; // address to read data = *pointer; // data to read while(1);}.
Hi TI Team,
Planning to use persistent, but still cannot read after boot:
http://dev.ti.com/tirex/explore/node?node=ALjQeIC7Hu5Y4ISuzhBZQw__IOGqZri__LATEST&search=MSP430FR2311
Regards,
Walter
Hello Walter,
Can you provide more information on what you mean by cannot read after boot?
Thanks,
Yiding
Hi Yiding,
I was just using simple persistent variable.
-------------------------------------------------
#pragma PERSISTENT(value)
unsigned long value = 0;
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
SYSCFG0 = FRWPPW; // Program FRAM write enable
value++;
SYSCFG0 = FRWPPW | PFWP; // Program FRAM write protecte
-----------------------------
Do I need to add this?
RTCCTL = 0;
PMMCTL0_H = PMMPW_H; // Open PMM Registers for write
PMMCTL0_L |= PMMREGOFF; // and set PMMREGOFF
PMMCTL0_H = 0; // Lock PMM Registers
I was expecting to be able to read the value saved after power cycle.
if(value)
{
// correcly writetn.
}
else{
// not correcly writetn.
}
Regards,
Walter
By definition, it should work like this.
|
1
2
|
#pragma PERSISTENT ( count ) uint16_t count = 0; |
creates the variable "count" and tells the code generation tools to place it in "persistent" memory; that is, the variable will be placed in FRAM, which is a persistent type of memory. Handled this way, your code can read and write the variable just like it's located in RAM, but its value will be retained even if power is removed from the device.
Hello Walter,
GROUP(READ_WRITE_MEMORY)
{
.TI.persistent : {} /* For #pragma persistent */
}
>FRAM
SYSCFG0 = FRWPPW; // Program FRAM write enable
value++;
SYSCFG0 = FRWPPW | PFWP; // Program FRAM write protecte
Thanks,
Yiding
Hello Walter,
How did you read the value after reset the power? If you use the debugger standard setting it will reset the value after you debug the device.
I just tried on a FR2311 Launchpad and here is the simple code to test PERSISTENT variable.
If the LED is on after boot that means the variable Port_event retained its value after reset the power.
#include <msp430.h>
// Statically-initialized variable
#ifdef __TI_COMPILER_VERSION__
#pragma PERSISTENT(Port_event)
unsigned long Port_event = 0;
#endif
void initGpio(void);
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// Configure GPIO
initGpio();
if(Port_event == 6)
{
P1OUT |= BIT0;
}
else
{
P1OUT &= ~BIT0;
}
while(Port_event <= 5)
{
SYSCFG0 = FRWPPW; // Program FRAM write enable
Port_event++; // Record the port event in FRAM
SYSCFG0 = FRWPPW | PFWP; // Program FRAM write protected (not writable)
}
while(1)
{
__no_operation();
}
}
void initGpio()
{
P1DIR = 0xFF; P2DIR = 0xFF;
P1REN = 0xFF; P2REN = 0xFF;
P1OUT = 0x00; P2OUT = 0x00;
// Disable the GPIO power-on default high-impedance mode
// to activate previously configured port settings
PM5CTL0 &= ~LOCKLPM5;
}
Thanks,
Yiding
Hello Walter,
For your program if you don't want to use watchdog then it should be disabled.
However, even if you enabled the watchdog timer and there is a watchdog timer reset it should not reset PERSISTENT variables.
Thanks,
Yiding
**Attention** This is a public forum