__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空间中,这个初始化的值就是FRAM的初始值。
一周热门 更多>