__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;
}
}
此帖出自小平头技术问答
不初始化就是说这段代码不需要依赖初始化默认行为比如全局变量初始化为0,或者没有其他初始化行为比如a[1]={0},启动时初始化没必要,因为你明确的知道初始数据内容的合法性你自己保障(否则你加这个keyword做什么?)。或者不能初始化,比如这段代码的地址指向器件寄存器地址,用这些地址加相应偏移来访问寄存器,你就不能初始化。
一周热门 更多>