MSP430FR5962IPNR型号在程序运行过程使用空的flash进行数据存储,每次写入数据到flash MCU就重启,不能写入数据到flash,请帮忙提供参考代码或者相关说明文档
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.
MSP430FR5962IPNR型号在程序运行过程使用空的flash进行数据存储,每次写入数据到flash MCU就重启,不能写入数据到flash,请帮忙提供参考代码或者相关说明文档
看例程
//******************************************************************************
// MSP430FR59xx Demo - Long word writes to FRAM
//
// Description: Use long word write to write to 512 byte blocks of FRAM.
// Toggle LED after every 100 writes.
// NOTE: Running this example for extended periods will impact the FRAM
// endurance. MPU is also enabled by default in CCS.
// MCLK = SMCLK = default DCO
//
// MSP430FR5969
// ---------------
// /|\| |
// | | |
// --|RST |
// | |
// | |
// | P1.0 |---> LED
//
// Kathryn Adamsky
// Texas Instruments Inc.
// July 2016 (Updated) | August 2012 (Created)
// Built with IAR Embedded Workbench V5.40 & Code Composer Studio V5.5
//******************************************************************************
#include <msp430.h>
#define WRITE_SIZE 128
void FRAMWrite(void);
unsigned char count = 0;
unsigned long data;
#if defined(__TI_COMPILER_VERSION__)
#pragma PERSISTENT(FRAM_write)
unsigned long FRAM_write[WRITE_SIZE] = {0};
#elif defined(__IAR_SYSTEMS_ICC__)
__persistent unsigned long FRAM_write[WRITE_SIZE] = {0};
#elif defined(__GNUC__)
unsigned long __attribute__((persistent)) FRAM_write[WRITE_SIZE] = {0};
#else
#error Compiler not supported!
#endif
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // Stop WDT
// Configure GPIO
P1OUT &= ~BIT0; // Clear P1.0 output latch for a defined power-on state
P1DIR |= BIT0; // Set P1.0 to output direction
// Disable the GPIO power-on default high-impedance mode to activate
// previously configured port settings
PM5CTL0 &= ~LOCKLPM5;