我之前往FLASH中写过一次0x55,但是用下面的测试代码读出来一直是0x55,
/* Erase the entire flash sector. */
NVS_erase(nvsHandle, 0, 32);
volatile uint8_t flag = 0;
int_fast16_t status = NVS_read(nvsHandle, 0, (uint8_t *)&flag, 1); /* 读取存储标志位 */
经排查是擦除没成功,想问一下FLASH读写擦 offset参数分别该怎么取值才正确?
Viki Shi:
NVS_erase()
int_fast16_t NVS_erase ( NVS_Handlehandle,
size_toffset,
size_tsize
)
Erase size bytes of the region beginning at offset bytes from the base of the region referenced by the NVS_Handle.Warning
Erasing internal flash on most devices can introduce significant interrupt latencies while the erase operation is in in progress. The user may want to surround certain real-time critical code sections with NVS_lock() and NVS_unlock() calls in order to prevent uncoordinated flash erase operations from negatively impacting performance.
Parameters
handle A handle returned from NVS_open()
offset The byte offset into the NVS region to start erasing from (must be erase sector aligned)
size The number of bytes to erase (must be integer multiple of sector size)
Return values
NVS_STATUS_SUCCESS Success.
NVS_STATUS_INV_ALIGNMENT If offset is not aligned on a sector boundary
NVS_STATUS_INV_OFFSET If offset exceeds region size
NVS_STATUS_INV_SIZE If size or offset + size exceeds region size, or if size is not an integer multiple of the flash sector size.
NVS_STATUS_ERROR If an internal error occurred erasing the flash.
user4959119:
回复 Viki Shi:
解决了,是之前上锁了。另外问一下,擦除4096个字节需要多长时间?
Viki Shi:
回复 user4959119:
TI中文支持网

