Hello all,
Does anyone know how to write data or values in FLASH?
Thanks in advance
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.
Hello all,
Does anyone know how to write data or values in FLASH?
Thanks in advance
Ok.
But I do not idea how to do it.
My application does the following:
I have two aplication: 1. myLight 2. mySwitch
On side my Switch I set value data, over sw1 and sw3, after set values, example data=5, I send to myLight.
Data is in the initial state one,therefore data=1. On switch side on display I show value of data which I set.
My light works with received value, which is data=5. After that, I again I set the value of data, example 10. after that I send data=10 to myLight device.
When I turn off mySwitch device, and I again turn on, on display of switch device will be show data=1(initial state).
But I want to display the last sent value, Therefore, in this case 10.
I need to write data to memory, after that then read it. How to do it?
Thanks in advance
You can use the following code to do write.
uint16 nv_data_id;
uint8 data;
data=...; //put the data value that you want to store to flash here and do write to flash
osal_nv_item_init(nv_data_id, 1, NULL);
osal_nv_write(nv_data_id, 0, 1, &data);
You can use the following code to do read.
osal_nv_item_init(nv_data_id, 1, NULL);
osal_nv_read(nv_data_id, 0, 1, &data);
You should put the code for write part to where you want to write the data and put the code for read to where you want to read data. It should be in your application C file.
This does not work.
This,
osal_nv_item_init(nv_data_id, 1, NULL);
osal_nv_write(nv_data_id, 0, 1, &data);
I put the place where I send data.
This,
osal_nv_item_init(nv_data_id, 1, NULL);
osal_nv_read(nv_data_id, 0, 1, &data);
I put in init function.
Immediately after reconnection, I need to read the value of data.
Yes, now working.
I define: #define nv_data_id 0x0049, and
I replaced osal_nv_item_init(nv_data_id, 1, NULL) with osal_nv_item_init(nv_data_id, 1, &data);
Thanks!