Showing results for 
Search instead for 
Did you mean: 

Smart Bluetooth

Not applicable


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.



1 Solution

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.


    // 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.



        case 1:

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


        case 2:




View solution in original post

2 Replies