Tool/software: TI-RTOS
Now I find a problem. The user data is saved to SNV, and the debugging finds that the data read out is all 0, and the data is not saved to SNV.
Using the osal_snv_write() and osal_snv_read() functions, access the ID 0x80.
The test code is as follows. This function is also called after osal_snv_init() :
void cc2541_MAC2snv_test(void)
{
uint8 nv_ret;
uint8 nv_data_read[128] =0;
uint8 nv_data_write[128] = 0;
uint8 ownAddress[B_ADDR_LEN];
ownAddress[0]=*(unsigned char *)(0x780E); // 直接指向指针内容
ownAddress[1]=*(unsigned char *)(0x780F);
ownAddress[2]=*(unsigned char *)(0x7810);
ownAddress[3]=XREG(0x7811); // define 函数直接读出数据
ownAddress[4]=XREG(0x7812);
ownAddress[5]=XREG(0x7813);
osal_memset(nv_data_write, 0, sizeof(nv_data_write)); //清空缓冲区后,作为接收缓冲区
nv_data_write[0]=ownAddress[0];
nv_data_write[1]=ownAddress[1];
nv_data_write[2]=ownAddress[2];
nv_data_write[3]=ownAddress[3];
nv_data_write[4]=ownAddress[4];
nv_data_write[5]=ownAddress[5];
nv_ret = osal_snv_write(0x80, 128, nv_data_write);
if(nv_ret!= NV_OPER_FAILED)
{
nv_ret = osal_snv_read(0x80, 128, nv_data_read);
}
}