假设初始化有:
osal_nv_item_init(ZCD_NV_LOCK,1,NULL); osal_nv_item_init(ZCD_NV_SL,1,NULL); osal_nv_item_init(ZCD_NV_LIN,1,NULL); osal_nv_item_init(ZCD_NV_SC,1,NULL); osal_nv_item_init(ZCD_NV_AU,1,NULL);
osal_nv_item_init(ZCD_NV_ISON,8,NULL); osal_nv_item_init(ZCD_NV_SETTED,3,NULL);
经过一段时间运行后,产品通过长按某按钮达到复位出厂设置的空值0xff,我通过如下方法处理:
osal_nv_item_init(ZCD_NV_LOCK,1,NULL); osal_nv_item_init(ZCD_NV_SL,1,NULL); osal_nv_item_init(ZCD_NV_LIN,1,NULL); osal_nv_item_init(ZCD_NV_SC,1,NULL); osal_nv_item_init(ZCD_NV_AU,1,NULL);
osal_nv_item_init(ZCD_NV_ISON,8,NULL); osal_nv_item_init(ZCD_NV_SETTED,3,NULL);
经过一段时间运行后,产品通过长按某按钮达到复位出厂设置的空值0xff,我通过如下方法处理:
处理方法1:
uint8 value[] ={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
osal_nv_write(ZCD_NV_LOCK,0,1,&value[0]);
osal_nv_write(ZCD_NV_SL,0,1,&value[0]);
osal_nv_write(ZCD_NV_LIN,0,1,&value[0]);
osal_nv_write(ZCD_NV_SC,0,1,&value[0]);
osal_nv_write(ZCD_NV_AU,0,1,&value[0]);
osal_nv_write(ZCD_NV_ISON,0,8,&value[0]);
osal_nv_write(ZCD_NV_SETTED,0,3,&value[0]);
方法1这样处理后,有时不能完全将NV里的值写成0xFF,为何?
方法2:
osal_nv_delete(ZCD_NV_LOCK,1); osal_nv_delete(ZCD_NV_SL,1); osal_nv_delete(ZCD_NV_LIN,1); osal_nv_delete(ZCD_NV_SC,1); osal_nv_delete(ZCD_NV_AU,1); osal_nv_delete(ZCD_NV_ISON,8); osal_nv_delete(ZCD_NV_SETTED,3); 方法2这样处理,是否有什么问题?或则是否有其它稳妥的方法,能把这些复位到烧录芯片后的初始值0xff
uint8 value[] ={0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff};
osal_nv_write(ZCD_NV_LOCK,0,1,&value[0]);
osal_nv_write(ZCD_NV_SL,0,1,&value[0]);
osal_nv_write(ZCD_NV_LIN,0,1,&value[0]);
osal_nv_write(ZCD_NV_SC,0,1,&value[0]);
osal_nv_write(ZCD_NV_AU,0,1,&value[0]);
osal_nv_write(ZCD_NV_ISON,0,8,&value[0]);
osal_nv_write(ZCD_NV_SETTED,0,3,&value[0]);
方法1这样处理后,有时不能完全将NV里的值写成0xFF,为何?
方法2:
osal_nv_delete(ZCD_NV_LOCK,1); osal_nv_delete(ZCD_NV_SL,1); osal_nv_delete(ZCD_NV_LIN,1); osal_nv_delete(ZCD_NV_SC,1); osal_nv_delete(ZCD_NV_AU,1); osal_nv_delete(ZCD_NV_ISON,8); osal_nv_delete(ZCD_NV_SETTED,3); 方法2这样处理,是否有什么问题?或则是否有其它稳妥的方法,能把这些复位到烧录芯片后的初始值0xff
Viki Shi:
变量前加上volatile试试