Other Parts Discussed in Thread: Z-STACK
Hello.
I have the genericApp example of the cc2538. I want to know where I record something in non-volatile memory and how to do it? Thank you!
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Other Parts Discussed in Thread: Z-STACK
Hello.
I have the genericApp example of the cc2538. I want to know where I record something in non-volatile memory and how to do it? Thank you!
Hi Samuel,
There is documentation regarding this in OSAL API.pdf (section 10), this comes with the SDK. In the code you can refer to OSAL_Nv.h
Basically you have to initialize an Nv ID with the length of the data to be store and the data (osal_nv_item_init), you have to know this Nv Id as you will have to refer to whenever you want to read/write the data. After being initialize you can read/write with the rest of the API (osal_nv_read, osal_nv_write)
Hope this helps!
I put the example code in GenericApp_Init and it build successfully. You can refer to the following codes in red.
void GenericApp_Init( uint8 task_id )
{
GenericApp_TaskID = task_id;
GenericApp_NwkState = DEV_INIT;
GenericApp_TransID = 0;
// Device hardware initialization can be added here or in main() (Zmain.c).
// If the hardware is application specific - add it here.
// If the hardware is other parts of the device add it in main().
GenericApp_DstAddr.addrMode = (afAddrMode_t)AddrNotPresent;
GenericApp_DstAddr.endPoint = 0;
GenericApp_DstAddr.addr.shortAddr = 0;
// Fill out the endpoint description.
GenericApp_epDesc.endPoint = GENERICAPP_ENDPOINT;
GenericApp_epDesc.task_id = &GenericApp_TaskID;
GenericApp_epDesc.simpleDesc
= (SimpleDescriptionFormat_t *)&GenericApp_SimpleDesc;
GenericApp_epDesc.latencyReq = noLatencyReqs;
// Register the endpoint description with the AF
afRegister( &GenericApp_epDesc );
// Register for all key events - This app will handle all key events
RegisterForKeys( GenericApp_TaskID );
// Update the display
#if defined ( LCD_SUPPORTED )
HalLcdWriteString( "GenericApp", HAL_LCD_LINE_1 );
#endif
ZDO_RegisterForZDOMsg( GenericApp_TaskID, End_Device_Bind_rsp );
ZDO_RegisterForZDOMsg( GenericApp_TaskID, Match_Desc_rsp );
#if defined( IAR_ARMCM3_LM )
// Register this task with RTOS task initiator
RTOS_RegisterApp( task_id, GENERICAPP_RTOS_MSG_EVT );
#endif
{
uint8 nv_test=0;
uint16 nv_test_id=0x0401;
osal_nv_item_init(nv_test_id, 1, NULL);
osal_nv_write(nv_test_id, 0, 1, &nv_test);
osal_nv_read(nv_test_id, 0, 1, &nv_test);
}
}