bleprofile_ReadNVRAM Return Value

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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

0 Likes
1 Solution
asridharan
Employee
Employee
10 comments on KBA 5 comments on KBA First comment on KBA

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:

        ......

    }

}

View solution in original post

2 Replies
asridharan
Employee
Employee
10 comments on KBA 5 comments on KBA First comment on KBA

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:

        ......

    }

}

Anonymous
Not applicable

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

0 Likes