TI论坛
直播中

黄鹏

7年用户 207经验值
私信 关注

使用API函数NVS_write写入时长度只允许是4的倍数吗?这个在哪可以修改吗?为什么?

本帖最后由 一只耳朵怪 于 2018-6-6 16:51 编辑

关于CC1310 Flash操作的问题:
使用API函数NVS_write写入时长度只允许是4的倍数吗?这个在哪可以修改吗?为什么?
目前需要其他长度字节写入,每次都要转换为4的倍数,浪费了Flash空间。

回帖(3)

庄当甜

2018-6-6 10:41:40
通过NVS_write()函数来写入,函数的第2个参数为起始地址,并且必须4字节对齐。
举报

李子月

2018-6-6 10:55:25
和芯片硬件结构有关系的!有的是单字节,有的是双字节,cortex m系列内部
flash通常4字节写。
                                                                         
提供德州仪器蓝牙和射频cc2540,cc2541,cc26系列,cc13系列脱机烧录工具。



 
举报

黄鹏

2018-6-6 11:26:29

有的,为啥咱们的.h不一样
/*!
* @brief Write data to an NVS block.
*
* @param handle A handle returned from NVS_open()
*
* @param offset The byte offset into the NVS block to start
* writing. offset must be 4-byte aligned.
*
* @param buffer A buffer conntaining data to write to
* the NVS block. If buffer is NULL, the block
* will be erased. A non-NULL buffer must be
* aligned on a 4-byte boundary.
*
* @param bufferSize The size of the buffer (number of bytes to write).
* bufferSize must be a multiple of 4 bytes.
*
* @param flags Write flags (NVS_WRITE_EXCLUSIVE, NVS_WRITE_ERASE,
* NVS_WRITE_VALIDATE).
*
* @return NVS_SOK Success.
* @return NVS_EOFFSET The location and size to write to does not
* lie completely within the NVS block.
* @return NVS_EALIGN The offset or bufferSize is not 4-byte aligned.
* @return NVS_ALREADYWRITTEN
* The region to write to (the bufferSize region
* starting at offset into the block) has already
* been written to since the last erase, and
* NVS_WRITE_EXCLUSIVE is set in the flags parameter.
*
* @remark This call may block to ensure atomic access to the block.
*/
extern int NVS_write(NVS_Handle handle, size_t offset, void *buffer,
size_t bufferSize, unsigned int flags);
举报

更多回帖

发帖
×
20
完善资料,
赚取积分