微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 无线和射频 > TI无线射频设计 > cc1310的flash读写问题

cc1310的flash读写问题

时间:12-23 整理:3721RD 点击:

NVS_init();
NVSHandle = NVS_open(0, &NVSParams);
int error = NVS_write(NVSHandle, 0x81, writebuf, 2, NVS_WRITE_ERASE);

int status = NVS_read(NVSHandle, 0x81, readbuf, 2);

我的读写flash时,出现跑到NVS_write函数时跑不下去了,请问下这是为什么?参数没设置对?如果是的话应该怎么设置?

可以参考下C:\TI\tirtos_cc13xx_cc26xx_2_16_01_14\products\cc13xxware_2_03_02_16941\driverlib里的例程

这里面有例程? 我只找到flash.c     flash.h的文件,不知道怎么调用里面的接口,具体的流程有没有?

试试下面这个

/**************************************************************************************************
Filename: hal_flash_wrapper.c
Revised: $Date: 2013-10-01 10:39:43 -0700 (Tue, 01 Oct 2013) $
Revision: $Revision: 35500 $

Description: This file implements the hal_flash interface for the flash driver.


Copyright 2005-2014 Texas Instruments Incorporated. All rights reserved.

IMPORTANT: Your use of this Software is limited to those specific rights
granted under the terms of a software license agreement between the user
who downloaded the software, his/her employer (which must be your employer)
and Texas Instruments Incorporated (the "License"). You may not use this
Software unless you agree to abide by the terms of the License. The License
limits your use, and you acknowledge, that the Software may not be modified,
copied or distributed unless embedded on a Texas Instruments microcontroller
or used solely and exclusively in conjunction with a Texas Instruments radio
frequency transceiver, which is integrated into your product. Other than for
the foregoing purpose, you may not use, reproduce, copy, prepare derivative
works of, modify, distribute, perform, display or sell this Software and/or
its documentation for any purpose.

YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
PROVIDED 揂S IS?WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
TEXAS INSTRUMENTS OR ITS LICENSORS BE LIABLE OR OBLIGATED UNDER CONTRACT,
NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
(INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.

Should you have any questions regarding your right to use this Software,
contact Texas Instruments Incorporated at www.TI.com.
**************************************************************************************************/

/* ------------------------------------------------------------------------------------------------
* Includes
* ------------------------------------------------------------------------------------------------
*/

#include "hal_board.h"
#include "hal_types.h"
#include <driverlib/flash.h>
#include <inc/hw_memmap.h>

uint8* HalFlashGetAddress( uint8 pg, uint16 offset );
/**************************************************************************************************
* @fn HalFlashRead
*
* @brief This function reads 'cnt' bytes from the internal flash.
*
* input parameters
*
* @param pg - Valid HAL flash page number (ie < 128).
* @param offset - Valid offset into the page (so < HAL_NV_PAGE_SIZE and byte-aligned is ok).
* @param buf - Valid buffer space at least as big as the 'cnt' parameter.
* @param cnt - Valid number of bytes to read: a read cannot cross into the next 32KB bank.
*
* output parameters
*
* None.
*
* @return None.
**************************************************************************************************
*/
void HalFlashRead(uint8 pg, uint16 offset, uint8 *buf, uint16 cnt)
{
halIntState_t cs;

// Calculate the offset into the containing flash bank as it gets mapped into XDATA.
uint8 *ptr = HalFlashGetAddress(pg, offset);

// Enter Critical Section.
HAL_ENTER_CRITICAL_SECTION(cs);

// Read data.
while (cnt--)
{
*buf++ = *ptr++;
}

// Exit Critical Section.
HAL_EXIT_CRITICAL_SECTION(cs);
}

/**************************************************************************************************
* @fn HalFlashWrite
*
* @brief This function reads 'cnt' bytes from the internal flash.
*
* input parameters
*
* @param addr - Valid HAL flash write address: actual addr / 4 and quad-aligned.
* @param buf - Valid buffer space at least as big as the 'cnt' parameter.
* @param cnt - Valid number of bytes to write: a write cannot cross into the next 32KB bank.
*
* output parameters
*
* None.
*
* @return None.
**************************************************************************************************
*/
void HalFlashWrite(uint32 addr, uint8 *buf, uint16 cnt)
{
FlashProgram( buf, addr, cnt );
}

/**************************************************************************************************
* @fn HalFlashErase
*
* @brief This function erases 'cnt' pages of the internal flash.
*
* input parameters
*
* @param pg - Valid HAL flash page number (ie < 128) to erase.
*
* output parameters
*
* None.
*
* @return None.
**************************************************************************************************
*/
void HalFlashErase(uint8 pg)
{
FlashSectorErase( (uint32)HalFlashGetAddress(pg, 0));
}

/**************************************************************************************************
* @fn HalFlashGetAddress
*
* @brief This function maps a page and offset to the flash address
*
* input parameters
*
* @param pg - Valid HAL flash page number (ie < 128).
*
* @param offset - Valid HAL flash offset (ie < 4096).
*
* output parameters
*
* None.
*
* @return flashAddr - the flash address to map to.
**************************************************************************************************
*/
uint8* HalFlashGetAddress( uint8 pg, uint16 offset )
{
#ifndef FEATURE_OAD
// Calculate the offset into the containing flash bank as it gets mapped into XDATA.
uint8 *flashAddr = (uint8 *)(offset + HAL_NV_START_ADDR) + ((pg % HAL_NV_PAGE_BEG )* HAL_FLASH_PAGE_SIZE);

return flashAddr;
#else //FEATURE_OAD
// The actual address is a 4-KiloByte multiple of the page number plus offset in bytes.
return (uint8*)((pg << 12) + offset);
#endif //FEATURE_OAD
}


/**************************************************************************************************
*/

你好! VIKI :

                 1. 我按这http://processors.wiki.ti.com/index.php/CC13xx_26xx_write_flash里面的方法设置,也不能读取数据。

                 NVSHandle = NVS_open(0 , &NVSParams);

                 VIMSModeSafeSet(VIMS_BASE, VIMS_MODE_DISABLED, 1);
                 VIMSLineBufDisable(0);
                 NVS_erase(NVSHandle);
                 NVS_write(NVSHandle, 0, writebuf, 2, NVS_WRITE_ERASE);
                 VIMSLineBufEnable(0);
                 VIMSModeSafeSet(VIMS_BASE, VIMS_MODE_ENABLED, 1);
                 NVS_read(NVSHandle, 0, readbuf, 2);

                 2.  C:\TI\tirtos_cc13xx_cc26xx_2_16_01_14\products\cc13xxware_2_03_02_16941\driverlib里的哪个例程,里面的都是.c 和 .h的文件,这个怎么个调用方法?有没有关于flash工程?

您好,您的问题解决了吗?我最近也在弄这个,也想通过NVS的API来实现FLASH的读写操作,想请教你问题。

在调用NVS的时候有一个NVS_config[]数组,这个数组在NVS.C中是这样定义的:extern const NVS_Config NVS_config[],那这个数组到底是在哪里定义的,而且初始化的定义是否有什么参数,或者说它的初始值是什么?

另外,TI说的 C:\TI\tirtos_cc13xx_cc26xx_2_16_01_14\products\cc13xxware_2_03_02_16941\doc\driverlib下有flash的操作文档,我看了看 是一些函数说明,具体的操作并没有告诉,而且是没有flash的工程的。

typedef struct NVS_Config {

/*! Pointer to a table of driver-specific implementations of NVS APIs */
NVS_FxnTable const *fxnTablePtr;

/*! Pointer to a driver specific data object */
void *object;

/*! Pointer to a driver specific hardware attributes structure */
void const *hwAttrs;
} NVS_Config;

没有例程,需要自己结合其它例程写一个,也不复杂,调用的函数都有现成的,在NVS.c中

读写参数不对,需要4字节对齐,另外不需要VIMSModeSafeSet相关函数,NVS函数内部有相应调用。建议读下NVSCC26xx.c中的代码就明白了。

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top