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

【求助】msp430fr5739的FRAM官网读写例程和官方库函数的几个问题

一共有三个问题

首先是官网的例程:

#include <msp430.h>

void FRAMWrite(void);

#define WRITE_SIZE 128
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 MCLK for 8MHz operation CSCTL0_H = 0xA5;
CSCTL1 |= DCOFSEL0 + DCOFSEL1; // Set max. DCO setting
CSCTL2 = SELA_0 + SELS_3 + SELM_3; // ACLK = VLO
CSCTL3 = DIVA_0 + DIVS_1 + DIVM_1; // MCLK = SMCLK = DCO/2
// Turn off temp sensor
REFCTL0 |= REFTCOFF; REFCTL0 &= ~REFON;

// Turn on LED P1DIR |= BIT0;
// Initialize dummy data
data = 0x11111111;

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[i] = data;
}
}

问题1.例程并没有出现地址或者指针(或者我没有找到),那么data究竟写在哪里了 

问题2.我要读出存在FRAM中data的值应该如何操作

其次是库函数:

 

void FRAMCtl_memoryFill32 (uint32_t value,
uint32_t *framPtr,
uint16_t count
)
{
while (count> 0)
{
//Write to Fram
*framPtr++ = value;
count–;
}
}

问题3:这个程序中的count是指向FRAM中写了count次value么?写16位数和写32位数FRAM指针变化一样么?

Susan Yang:

MSP430的整个FRAM存储区域都包含在C200-FF7F(16k)中,无论代码和常量以及全局变量都可以定义在这个范围.

Using PERSISTENT, the default linker files place all read + write variables at the beginning of the FRAM on the part. But if you add/remove/change size of the variables they may end up within slightly different addresses within that grouping. But as I said there are very few use-cases where you would need to actually set a specific absolute address – the beauty of using a variable/array though is that you don't need to know the absolute address.

您可以参考下E2E上的帖子 e2e.ti.com/…/616910 以及 e2e.ti.com/…/485532

灰小子:

1、写操作的地址是PERSISTENT定义的段
2、直接读取相应地址的数据就可以
3、count应该是还有多少存储空间

赞(0)
未经允许不得转载:TI中文支持网 » 【求助】msp430fr5739的FRAM官网读写例程和官方库函数的几个问题
分享到: 更多 (0)