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

cc1310如何把一个字节数据写入指定的flash地址中

大家好,

    请问在CC1310中如何实现把一个字节数据写入到指定的flash地址中呢?

    类似msp430功能实现:

unsigned long * Flash_ptrC;// Initialize Flash pointer Seg Dunsigned long tmp;tmp = value;Flash_ptrC = (unsigned long *) 0x1880;// Initialize Flash pointerFCTL3 = FWKEY;// Clear Lock bitFCTL1 = FWKEY+ERASE;// Set Erase bit*Flash_ptrC = 0;// Dummy write to erase Flash segwhile(FCTL3&BUSY);FCTL1 = FWKEY+BLKWRT;// Enable long-word write*Flash_ptrC = tmp;// Write to Flashwhile(FCTL3&BUSY);FCTL1 = FWKEY;// Clear WRT bitFCTL3 = FWKEY+LOCK; 

    希望能尽快得到帮助!

谢谢!

Viki Shi:

可以通过NVS driver,推荐个例程: dev.ti.com/…/

Mings Liu:

回复 Viki Shi:

谢谢Viki Shi,

   我是应用IAR7.80进行搭建的环境,TI协议为tirtos_cc13xx_cc26xx_2_20_01_08,配置NVS MAPPING

/*!*@defCC1310_LAUNCHXL_NVSName*@briefEnum of NVS names*/typedef enum CC1310_LAUNCHXL_NVSName {CC1310_LAUNCHXL_NVSCC26XX0 = 0,CC1310_LAUNCHXL_NVSSPI25X0,CC1310_LAUNCHXL_NVSCOUNT} CC1310_LAUNCHXL_NVSName;/**=============================== NVS ===============================*/#include <ti/drivers/NVS.h>#include <ti/drivers/nvs/NVSCC26XX.h>#define NVS_REGIONS_BASE 0x1A000#define SECTORSIZE0x1000#define REGIONSIZE(SECTORSIZE * 4)#define SPIREGIONSIZE(SECTORSIZE * 32)#define VERIFYBUFSIZE64static uint8_t verifyBuf[VERIFYBUFSIZE];/** Reserve flash sectors for NVS driver use by placing an uninitialized byte* array at the desired flash address.*/#if defined(__TI_COMPILER_VERSION__)/** Place uninitialized array at NVS_REGIONS_BASE*/#pragma LOCATION(flashBuf, NVS_REGIONS_BASE);#pragma NOINIT(flashBuf);static char flashBuf[REGIONSIZE];#elif defined(__IAR_SYSTEMS_ICC__)/** Place uninitialized array at NVS_REGIONS_BASE*/static __no_init char flashBuf[REGIONSIZE] @ NVS_REGIONS_BASE;#elif defined(__GNUC__)__attribute__ ((section (".nvs")))static char flashBuf[REGIONSIZE];#endif/* Allocate objects for NVS and NVS SPI */NVSCC26XX_Object nvsCC26xxObjects[1];/* Hardware attributes for NVS */const NVSCC26XX_HWAttrs nvsCC26xxHWAttrs[1] = {{.regionBase = (void *)flashBuf,.regionSize = REGIONSIZE,},};/* NVS Region index 0 and 1 refer to NVS and NVS SPI respectively */const NVS_Config NVS_config[CC1310_LAUNCHXL_NVSCOUNT] = {{.fxnTablePtr = &NVSCC26XX_fxnTable,.object = &nvsCC26xxObjects[0],.hwAttrs = &nvsCC26xxHWAttrs[0],},{NULL, NULL, NULL},};

NVS程序

 

NVS_Handle rHandle;NVS_Attrs regionAttrs;NVS_Params nvsParams;uint_fast16_t status;char buf[32];// Initialize the NVS driverNVS_init();NVS_Params_init(&nvsParams);rHandle = NVS_open(CC1310_LAUNCHXL_NVSCC26XX0, &nvsParams);// confirm that the NVS region opened properlyif (rHandle == NULL) {// Error opening NVS driverwhile (1);}// fetch the generic NVS region attributesNVS_getAttrs(rHandle, &regionAttrs);

在运行到NVS_OPEN();后返回NULL,这个是什么问题。

通过CCS编译正常。

谢谢!

Viki Shi:

回复 Mings Liu:

CCS正常,IAR出错,按描述应该是编译环境问题,IAR版本是否符合release note的要求?

Mings Liu:

回复 Viki Shi:

tirtos_cc13xx_cc26xx_2_20_01_08的release note是支持IAR7.80的,但是建立工程后的CC1310_LAUNCHXL.c中没有NVS配置信息,我是从simplelink_cc13x0_sdk_2_10_00_36中借鉴过来的,simplelink是需要IAR: 8.20.2.58 。如果真是版本问题就麻烦了,我之前的工程都是在IAR7.80上建立的。如果我还是用IAR7.80,NVS配置上需要怎么修改呢?
谢谢!

Viki Shi:

回复 Mings Liu:

建议换到新版本,然后根据SDK中的migration guide来移植

赞(0)
未经允许不得转载:TI中文支持网 » cc1310如何把一个字节数据写入指定的flash地址中
分享到: 更多 (0)