__persistent unsigned long FRAM_write[WRITE_SIZE] = {0};
这句话是什么意思?__persistent是什么用法?求教大神解释
顺便附上整体程序:
#include "msp430.h"
void FRAMWrite(void);
unsigned char count = 0;
unsigned long data;
#define WRITE_SIZE 128
#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}; //这句何解?
#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;
// Initialize dummy data
data = 0x00010001;
while(1)
{
data += 0x00010001;
FRAMWrite(); // Endless loop
count++;
if (count > 100)
{
P1OUT ^= 0x01; // Toggle LED to show 512K bytes
count = 0; // ..have been written
data = 0x00010001;
}
}
}
void FRAMWrite(void)
{
unsigned int i=0;
for ( i= 0; i<WRITE_SIZE; i++)
{
FRAM_write
= data;
}
}
此帖出自小平头技术问答
加了那个关键字,就会把你定义的数组强制放在FRAM的地址上去,如果不加,只是普通的全局变量,就会放在RAM的地址去,这样掉电的话,数据会被清掉
一周热门 更多>