TI中文支持网
TI专业的中文技术问题搜集分享网站

msp430fr5739 FRAM读写问题

 普通学生,最近在做东西的时候对fram的读写的C语言程序很迷糊,请问应该学习些什么?

Seven Han:

以下链接是WIKI上提供的相关MSP430FR5739 FRAM的Training供参考。
processors.wiki.ti.com/…/MSP430_FR57xx_Training_Workshop

灰小子:

建议先运行下官网例程,通过例程来学习

user5176142:

回复 灰小子:

#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

请问例程代码这段宏定义中的__((persistent)) FRAM_write[WRITE_SIZE] = {0};   有什么意义,不太理解,查阅数据手册说的很模糊

Susan Yang:

Here is example code which should show you how to use data in FRAM.

#include <msp430.h>#define WRITE_SIZE128void 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!
#endifint main(void)
{WDTCTL = WDTPW | WDTHOLD;// Stop WDT// Configure GPIOP1OUT &= ~BIT0;// Clear P1.0 output latch for a defined power-on stateP1DIR |= BIT0;// Set P1.0 to output direction// Disable the GPIO power-on default high-impedance mode to activate// previously configured port settingsPM5CTL0 &= ~LOCKLPM5;// Initialize dummy datadata = 0x00010001;while(1){data += 0x00010001;FRAMWrite();count++;if (count > 100){P1OUT ^= 0x01;// Toggle LED to show 512K bytescount = 0;// ..have been writtendata = 0x00010001;}}
}void FRAMWrite(void)
{unsigned int i = 0;for (i = 0; i < WRITE_SIZE; i++){FRAM_write[i] = data;}
}

Hao Mengzhen:

回复 user5176142:

你看到前面的#if defined没? 一般编译器如CCS,运行你这段程序时只会执行这句#pragma PERSISTENT(FRAM_write) 在FRAM中生成地址的。同理unsigned long __attribute__((persistent)) FRAM_write[WRITE_SIZE] = {0};  的作用同#pragma PERSISTENT(FRAM_write) 只是编译器不同罢了。

user5176142:

回复 Hao Mengzhen:

条件编译看见了,能详细说一下FRAM_write[WRITE_SIZE] = {0},这句么?

Hao Mengzhen:

回复 user5176142:

这个没什么好纠结的吧?就像定义一个向量一样,a[n]={0}.

灰小子:

回复 user5176142:

就是定义一个数组,每个元素都是0

赞(0)
未经允许不得转载:TI中文支持网 » msp430fr5739 FRAM读写问题
分享到: 更多 (0)