Hello ~
請問有沒有 fram 當 EEPROM 的 讀/寫 Sample code ??
謝謝
Ryan
灰小子:
对fram的写操作应该就算当作eeprom吧
/* --COPYRIGHT--,BSD* Copyright (c) 2017, Texas Instruments Incorporated* All rights reserved.** Redistribution and use in source and binary forms, with or without* modification, are permitted provided that the following conditions* are met:** *Redistributions of source code must retain the above copyright*notice, this list of conditions and the following disclaimer.** *Redistributions in binary form must reproduce the above copyright*notice, this list of conditions and the following disclaimer in the*documentation and/or other materials provided with the distribution.** *Neither the name of Texas Instruments Incorporated nor the names of*its contributors may be used to endorse or promote products derived*from this software without specific prior written permission.** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.* --/COPYRIGHT--*/ //****************************************************************************** //!Long word writes to FRAM //! //!Description: Use long word write to write to 512 byte blocks of FRAM. //!Toggle LEDs after every 100 writes. //!NOTE: Running this example for extended periods will impact the FRAM //!endurance. //!ACLK = VLO, MCLK = SMCLK = ~1.048MHz //! //!MSP430FR2xx_4xx Board //!--------------- //!/|\|| //!| || //!--|RST| //!|| //!|| //!||-->LED1 //!||-->LED2 //! //****************************************************************************** #include "driverlib.h" #include "Board.h"#define FRAM_TEST_START 0xCABAvoid main(void) {uint8_t count = 0;uint32_t data = 0;// Stop WDTWDT_A_hold(WDT_A_BASE);//Set LED1 as an output pin.GPIO_setAsOutputPin(GPIO_PORT_LED1,GPIO_PIN_LED1);//Set LED2 as an output pin.GPIO_setAsOutputPin(GPIO_PORT_LED2,GPIO_PIN_LED2);/** Disable the GPIO power-on default high-impedance mode to activate* previously configured port settings*/PMM_unlockLPM5();// Initialize dummy datadata = 0x11111111;while (1) {data += 0x00010001;FRAMCtl_fillMemory32(data, (uint32_t *) FRAM_TEST_START,128);count++;if (count > 100) {//Toggle LED1 output pin.GPIO_toggleOutputOnPin(GPIO_PORT_LED1, GPIO_PIN_LED1);//Toggle LED2 output pin.GPIO_toggleOutputOnPin(GPIO_PORT_LED2, GPIO_PIN_LED2);//Reset countercount = 0;data = 0x11111111;}} }
Ryan wen1:
Hello ~
感謝回覆 !!
以下這行 , 看起來應該是可以寫入資料到 fram , 但要如何讀出資料呢 ?
FRAMCtl_fillMemory32(data, (uint32_t *) FRAM_TEST_START, 128);
Thanks !!
Ryan
Susan Yang:
回复 Ryan wen1:
您可以看一下 www.ti.com/…/slaa628.pdf 以及 e2e.ti.com/…/1736699
灰小子:
回复 Ryan wen1:
直接读取相应地址就可以
Ryan wen1:
回复 灰小子:
我的程序如下 , 可以讀寫 , 但不能掉電保存 , 可不可以幫忙一下…… 謝謝
( msp430FR2433的 FRAM 作EEPROM的功能 !!!)#define FRAM_TEST_START 0xCABA
unsigned int data;
unsigned int *FRAM_write_ptr;
unsigned char wp ;
unsigned charstate ;void main(void)
{unsigned char dd[12];unsigned char i ;
for(i=0;i<8;i++)dd[i] = FRAM_Read(i);FRCTL0 = FRCTLPW | NWAITS_7;/* Frame wait state enable */wp = DFWP | PFWP;state = HWREG8(SYS_BASE + OFS_SYSCFG0_L);HWREG16(SYS_BASE + OFS_SYSCFG0) = FWPW | (state & ~wp);
for(i=0;i<8;i++)dd[i] = FRAM_Read(i);while(1){for(i=0;i<8;i++) FRAM_Write(i , 0xcc);P1OUT ^= BIT0;
for(i=0;i<8;i++)dd[i] = FRAM_Read(i);P1OUT ^= BIT0;}
}
//***************************************************************************************
//***************************************************************************************unsigned char FRAM_Read(unsigned char Offset )
{FRAM_write_ptr = (unsigned int *)FRAM_TEST_START;return *(FRAM_write_ptr+Offset);
}//***************************************************************************************
//***************************************************************************************void FRAM_Write(unsigned char Offset , unsigned char data)
{FRAM_write_ptr = (unsigned int *)FRAM_TEST_START;SYSCFG0 &= ~DFWP;*(FRAM_write_ptr+Offset) = data;SYSCFG0 |= DFWP;
}//***************************************************************************************
//***************************************************************************************
灰小子:
回复 Ryan wen1:
你的意思是调电后FRAM_TEST_START及之后地址上的数据就没有了吗?
你怎么检查的?有没有读出来显示在显示屏或者串口发送的上位机看看?
Ryan wen1:
回复 灰小子:
dirtwillfly
你的意思是调电后FRAM_TEST_START及之后地址上的数据就没有了吗?
你怎么检查的?有没有读出来显示在显示屏或者串口发送的上位机看看?
Xiaodong LI:
回复 Ryan wen1:
如果想利用MSP的FRAM模拟独立的串口的EEPROM IC, 请参考这个www.ti.com/…/tidubi8a.pdf
Xiaodong LI:
回复 Xiaodong LI:
如果是在同一片单片机上存储参数的需求,可以参考官方样例程序中framwrite.c的程序。FRAM读写读写操作都非常直观,FRAM不需要片擦除,唯一需要注意的是SYSCFG0上的DFWP(write protection)。www.ti.com/…/getliterature.tsp