2 Replies Latest reply on Mar 24, 2015 12:34 AM by kilian.timmler@exelonix.com

    bleprofile_ReadNVRAM Return Value

      Hi,

       

      I just noticed that when I just programmed the 20736S I'm using now, the return value of bleprofile_ReadNVRAM() is 0. I get the same value if some form of read error occurred. Now I have the problem that I have to be able to detect the read error and act differently compared to the case where NVRAM has not been written yet.

       

      One avenue I'm thinking about is using some battery buffered register to store the configuration state. There are some RTCs out there in the wild that offer that possibility and you have this most intriguing set of functions called mia_xyzKeepstateN(). Please let me know whether I can use them for this purpose or whether they serve some different function.

       

      Regards,

       

      Kilian

        • 1. Re: bleprofile_ReadNVRAM Return Value
          ArvindS_76

          mia_xyzKeepstateN() only provides 32 bits (of which keep state 0, bit 0 is reserved, leaving the app 31 bits) of storage in deep sleep/hid-off. Anything stored here will be lost on power cycle (unlike with a real NV store). So you can do something like this:

           

          void app_enter_deep_sleep(UINT 8 keep_this)

          {

              // Store value in keep state 1 and ender deep sleep.

              mia_addKeepstate1(keep_this);

           

              // EDIT:

              // Enter deep sleep here using your favorite mechanism.

          }

           

          void application_create(void)

          {

              // Do some app init here.

           

              // Then read keep state register to see what was stored before entering deep sleep and

              // do something.

              switch(mia_getKeepstate1())

              {

                  case 1:

                      // Do something if 1 was stored by app_enter_deep_sleep before entering deep sleep last time.

                      break;

                  case 2:

                  ......

              }

          }

          1 of 1 people found this helpful
          • 2. Re: bleprofile_ReadNVRAM Return Value

            This is great information, thanks a lot.

             

            The fact that a power outage could cause data loss is indeed a problem. People could throw the device we are building and the battery could become disconnected for a few tens of milliseconds, then it becomes a question of whether the 250µF capacitor bank we have on board can buffer the power loss. Oh, it should do so for 40s, this is nice I have to test this some day.

             

            I do have other issues with the bleprofile_ReadNVRAM() function but I will start another thread for it.

             

            Regards,

             

            Kilian