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

why the fs_sys_event_handler() can't be called--when use fstorage to write flash?

SDK11, NRF51822

if I use the fstorage_test at the applicaiton_init(void), then runs ok.

but on my product, I use a key to power the system, if I use the fstorage_test() in the   power on function(), then the fs_sys_event_handler() can't be called, code as following:

Can someone help me?

Parents Reply
  • It's can't be set volatile, for every time before store or erase ,it's should be set 1 by user. I wonder how to use schedule handling library, Is there any example?

Children
  • Hi,

    I do not know if it is an error in translation, but what I meant by "declare volatile" is you must define the variable with the "volatile" keyword. This tells the compiler that the value must be read from and written to memory every time it is used. If it is not "volatile", the compiler may hold the value in a CPU register or even optimize the code in such a way that the variable is never used. When you set and clear a flag in one context, and check for the flag in another context, you must always use a volatile variable for that flag.

    Please have a look at the Schedule handling library documentation. In nRF5 SDK v11, it is used for instance in the HID Keyboard and Mouse examples and in the Eddystone example.

    Regards,
    Terje

  • tesc, thank you very much! first i Misunderstanding the volatile, now I fixed it , and I use schedule to try it, code as follow:

    this time I found app_sched_event_put can be execute, but the function write_flash() can't be called, I don't know any question occur here. can you help me, thanks again!

  • OK, I solved it. it's the function app_sched_event_put return  NRF_ERROR_INVALID_LENGTH. I redefine the parameters of APP_SCHED_INIT();and now is ok!Thank you,tesc, thank you ,msromero!