This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Problem with pstorage s110 v6

I have a strange problem with pstorage function with nrf51822 with s110 v6. I need to use nrf_delay ( about 1 second long ) after store and before read. This is the source code: http://pastebin.com/snS78vnf My workflow is that: Clear the data, wait for the callback function When clear callback function call, write to the memory When write callback function call, load to the memory

From this behaviour. I think that it may relate to the problem that pstorage will not take care for the case the chip sleeps or something like this. Is there anyway I can improve this code without the nrf_delay

Parents
  • Be careful, nrf_delay function uses 99% of the CPU. Therefore, the pstorage task (or other interrupt) cannot be proceeded. You should avoid using this kind of functions.

    Also, because PStorage is asynchronous, your data to store MUST BE gobal. Else, it is possible that your are no longer in the same context of your data and the memory would be reallocated for others things.

  • Yeah it's weird. Because if I move the data to global it will return error And I use the callback fucntion. After I call store function the callback function will be called but when I check with pstorage_access_status_get(&count);. Count value is 1 and not 0. So I don't know what's wrong here. But then when I add nrf_delay everything works. I don't really understand why it only works this way. I'm just start with embedded for 1 month. So I think I may miss something important here.

Reply
  • Yeah it's weird. Because if I move the data to global it will return error And I use the callback fucntion. After I call store function the callback function will be called but when I check with pstorage_access_status_get(&count);. Count value is 1 and not 0. So I don't know what's wrong here. But then when I add nrf_delay everything works. I don't really understand why it only works this way. I'm just start with embedded for 1 month. So I think I may miss something important here.

Children
No Data
Related