14 posts / 0 new
Last post
anushiya
Offline
Last seen: 5 hours 2 min ago
Joined: 2017-12-20 02:30
MNF_DATA update and ARCH_EXT_SLEEP_ON

Hi,

I am having trouble in setting up the extended sleep mode (without OPT copy). We are using custom 14586 board.

In arch_main.c, in the procedure int main (void) (line 139)

if I replace sleep_mode = rwip_power_down(); (line 176) with sleep_mode = mode_active; It transmit the data continuously every one second without problem.

But if I leave sleep_mode = rwip_power_down()  the packet does not get updated. After initialisation, the packet is updated once and then it transmit the same packet every one second.

Adv_data_update_timer_cb is scheduled using APP_ADV_DATA_UPDATE_TO is not changed and left as 100

CFG_MAX_SLEEP_DURATION_PERIODIC_WAKEUP_MS is left at 500.

Tried values 687.5 and 3000 for .intv_min and .intv_max 

app_default_sleep_mode is set as ARCH_EXT_SLEEP_ON

all arch_set_extended_sleep calls are called with parameter false (arch_set_extended_sleep(false) ).

app_easy_gap_non_connectable_advertise_start(); used.

SysCLK changed to 16MHz.

Timer 0 and systick used for setting certain values of MNF_DATA.

I have two problems,

1) The packet does not get updated

2) Looking at the current level on smartsnippets and from test point 6 of the development board, I don't think it is going into sleep mode. (On the CRO the base voltage is 100mv and when transmit it goes to 400mV.

Can I please get some help on this please? I started the project from your ble_app_sleepmode and modified to suit our need.  

Thank you

Device: 
PM_Dialog
Offline
Last seen: 10 hours 56 min ago
Staff
Joined: 2018-02-08 11:03
Hi anushiya,

Hi anushiya,

In order to set the DA14586 in extended sleep mode without OTP mirroring, all you have to do is just to set the app_default_sleep_mode variable in user_config.h to ARCH_EXT_SLEEP_ON. You should not modify the arch_main.c file as it is SDK related file. In the ble_app_sleepmode example of the SDK, the device advertises for a defined amount of time APP_ADV_DATA_UPDATE_TO with a default value of 30 s. While the device is in the advertising state its sleep mode is set to Extended sleep with OTP copy (the OTP copy is emulated when the system runs in DEVELOPMENT_DEBUG mode). After the expiration of the above timeout, and if the device does not enter the connected state, it stops advertising, so the adv_data_update_timer_cb() which executes the app_easy_gap_advertise_stop(). This means that the manufacturer specific data will not be updated and the device will enter the extended sleep mode waits for an external event to exit the sleeping state. The user can wake up the device by pressing a button. After the button press the device will start to advertise again for the predefined time. When the device enters the connected state then the sleep mode is turned to Extended sleep without OTP copy. So, if you would like to update the manufacturer specific data, you should set up a second timer in the user_app_adv_start(). For getting more information with the sleep modes in DA14585/6 product family, please read the Tutorial 4: Sleep modes current measurement .

Thanks, PM_Dialog

anushiya
Offline
Last seen: 5 hours 2 min ago
Joined: 2017-12-20 02:30
Thank you for your prompt

Thank you for your prompt reply. I do not want a connected state and want to abuse the system to indefinitely transmit one packet ever x sec. 

> You should not modify the arch_main.c file as it is SDK related file.

I didn't change anything here. Only to make it tranmit continuosly, I temporarily replace sleep_mode = rwip_power_down(); (line 176) of arch_main.c with sleep_mode = mode_active and confirmed that it transmit continuosly.

>  app_default_sleep_mode variable in user_config.h to ARCH_EXT_SLEEP_ON

I've done this

> In the ble_app_sleepmode example of the SDK, the device advertises for a defined amount of time APP_ADV_DATA_UPDATE_TO with a default value of 30 s. While the device is in the advertising state its sleep mode is set to Extended sleep with OTP copy (the OTP copy is emulated when the system runs in DEVELOPMENT_DEBUG mode). After the expiration of the above timeout, and if the device does not enter the connected state, it stops advertising, so the adv_data_update_timer_cb() which executes the app_easy_gap_advertise_stop(). This means that the manufacturer specific data will not be updated and the device will enter the extended sleep mode waits for an external event to exit the sleeping state.

I have commented app_easy_gap_advertise_stop() in adv_data_update_timer_cb() and replaced with app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb); and have set APP_ADV_DATA_UPDATE_TO to 100

(This is why when I change sleep_mode = mode_active in arch_main.c, it transmit indefinitely)

I do not want a connected state and want to indefinitely transmit one packet ever x sec

> The user can wake up the device by pressing a button. After the button press the device will start to advertise again for the predefined time. When the device enters the connected state then the sleep mode is turned to Extended sleep without OTP copy. So, if you would like to update the manufacturer specific data, you should set up a second timer in the user_app_adv_start().

I want the device to never expect a button press. Also the device will never enter contected state. I want the device to transmit a paket in a specific interval and go into Extended sleep without OTP copy. That's why I've changed  app_easy_gap_undirectional_advertise_start();  as app_easy_gap_non_connectable_advertise_start(); 

and also all arch_set_extended_sleep calls are called with parameter false (arch_set_extended_sleep(false) ). Original exaple had arch_set_extended_sleep(true)

 

>For getting more information with the sleep modes in DA14585/6 product family, please read the Tutorial 4: Sleep modes current measurement .

This is what exactly I used. I tried two ways. 1) using smartsnippets to put the code in the flash so that JTAG doesn't need to be connected. 2) in Keil_5 pressed debug and let the program run and then come out of debug. both times the correct remained high.

Thank you very much for your help.

Please note that I could send you the full project setup if I could upload a larger file or if you specifically want to see a certain file, I could upload that.

PM_Dialog
Offline
Last seen: 10 hours 56 min ago
Staff
Joined: 2018-02-08 11:03
Hi anushiya,

Hi anushiya,

Thank you for your detailed feedback.

  • I didn't change anything here. Only to make it tranmit continuosly, I temporarily replace sleep_mode = rwip_power_down(); (line 176) of arch_main.c with sleep_mode = mode_active and confirmed that it transmit continuosly.

Which SDK version you are using? I am using the latest version which is SDK6.0. 10. I could find the sleep_mode = rwip_power_down(); in line 195 in the arch_main.c file. In the while(1) loop, if you replace the rwip_power_down() with mode_active, it seem that the device will never go into sleep mode.

  • I want the device to never expect a button press. Also the device will never enter contected state. I want the device to transmit a paket in a specific interval and go into Extended sleep without OTP copy. That's why I've changed  app_easy_gap_undirectional_advertise_start();  as app_easy_gap_non_connectable_advertise_start();

You count configure the device as broadcaster or use non-connectable advertising. When a device acts as a broadcaster, that means that its able to support only non-connectable advertising. Please follow the steps below in order to configure your device as broadcaster. I made these steps in the ble_app_sleepmode example of the SDK6.0.10

  1. Change to GAP_BROADCASTER_MODE the .mode item of the user_adv_conf structure in the user_config.h header file
  2. Change to GAP_ROLE_BROADCASTER the .role item of the user_gapm_conf structure in the user_config.h header file.
  3. Add cmd =app_easy_gap_non_connectable_advertise_get_active(); instead of the cmd = app_easy_gap_undirected_advertise_get_active(); in user_app_adv_start() function of the user_sleepmode.c file
  4. Add the app_easy_gap_non_connectable_advertise_start(); instead of the app_easy_gap_undirected_advertise_start();in user_app_adv_start() function of the user_ sleepmode.c file
  5. Add a user_app_on_adv_nonconn_complete() function as the user_app_adv_undirect_complete(). This function will be triggered when the non-connectable advertising completes.
  6. Add the user_app_on_adv_nonconn_complete in the user_app_callbacks structure of the user_callback_config.h header file as follow : .app_on_adv_undirect_complete   = user_app_adv_undirect_complete,

If you found any answer useful, please mark it as “accepted”.

Thanks, PM_Dialog

anushiya
Offline
Last seen: 5 hours 2 min ago
Joined: 2017-12-20 02:30
Thank you for your help. Your

Thank you for your help. Your advice helped me put the device on broadcast mode. But still have the following two issues.

1) The mnf_data_update() is still not invoked and

2) smartsnippets showing 0.5mA with spikes during transmission times (with debug mode removed) implying sleep mode is not invoked.

(Using the oscilloscope, via test points on the mother board matches the smartsnippets values)

I am using SDK 6.0.4.326. 

I defined user_app_adv_non_connectable_complete(uint8_t) as

void user_app_adv_non_connectable_complete(uint8_t status)

{

//irespective of the status, schedule the next transmission packet

app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb);

}

where APP_ADV_DATA_UPDATE_TO = 3000 - This shouldn't have any effect in broadcast any way

all arch_set_extended_sleep calls are with parameter "false" for no OTP programming

app_default_sleep_mode = ARCH_EXT_SLEEP_ON

 

PM_Dialog
Offline
Last seen: 10 hours 56 min ago
Staff
Joined: 2018-02-08 11:03
Hi anushiya,

Hi anushiya,

I would like to let you know the SDK6.0.4 is a very old version and it is not currently supported. To do so, I would strongly recommend you to download and use the latest version of SDK for DA14585/6 product family, which is SDK6.0.10. The ble_app_sleep mode example of the SDK6.0.10 is used for the steps I provided you in order to set  your in device in broadcaster mode.  The user_app_adv_non_connectable_complete() will be triggered every time that the non-connectable advertising is completed. So, you set up a timer inside this function, and when the timer expires, the adv_data_update_timer_cb will be executed.  Please follow the guidelines for configuring the device to broadcaster mode, in the ble_app_sleepmode example of the SDK. I would suggest you to do only the modifications I provided you.  The non-connectable advertising will stop every APP_ADV_DATA_UPDATE_TO and the adv_data_update_timer_cb() will be triggered. Check the user_app_adv_start(). As soon as the timer expires, the manufacturer specific data will be updated on the flight, the advertising will be stopped, and the device will go into extended sleep mode. The manufacture data are stored into the retention RAM, so when the chip wakes up with the button pressing, the adverting date will be updated.  If you want to update the manufacturer data while the device is adverting, you should set up a second timer. So you will have a timer to stop adverting and a second timer to update the manufactured specific data.

Thanks, PM_Dialog

anushiya
Offline
Last seen: 5 hours 2 min ago
Joined: 2017-12-20 02:30
Thank you. I'll upgrade to 6

Thank you. I'll upgrade to 6.0.10

> so when the chip wakes up with the button pressing, the adverting date will be updated.  

I want a periodic wake up and not a button press wakeup.. There is nointeraction from outside world.

> If you want to update the manufacturer data while the device is adverting, you should set up a second timer. So you will have a timer to stop adverting and a second timer to update the manufactured specific data.

I don't need this. Wake up, Transmit, update, sleep is fine for me.

So in the complete function, if I schedule as I mentioned is it fine?

 

Thank you.

Hi,

I downloaded SDK 6.0.10.511 and did the changes you suggested.

  1. Change to GAP_BROADCASTER_MODE the .mode item of the user_adv_conf structure in the user_config.h header file
  • Changed from GAP_GEN_DISCOVERABLE to GAP_BROADCASTER_MODE

 

  1. Change to GAP_ROLE_BROADCASTER the .role item of the user_gapm_conf structure in the user_config.h header file.
  • Changed from GAP_GEN_DISCOVERABLE to GAP_ROLE_BROADCASTER

 

  1. Add cmd =app_easy_gap_non_connectable_advertise_get_active(); instead of the cmd = app_easy_gap_undirected_advertise_get_active(); in user_app_adv_start() function of the user_sleepmode.c file

 

  1. Add the app_easy_gap_non_connectable_advertise_start(); instead of the app_easy_gap_undirected_advertise_start();in user_app_adv_start() function of the user_ sleepmode.c file

 

  1. Add a user_app_on_adv_nonconn_complete() function as the user_app_adv_undirect_complete(). This function will be triggered when the non-connectable advertising completes.
  • In user_sleepmode.c added as

void user_app_on_adv_nonconn_complete(uint8_t status)

{

//schedule the next advertising data update

app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb);

}

  • In user_sleepmode.c added

void user_app_on_adv_nonconn_complete(uint8_t status);

 

  1. Add the user_app_on_adv_nonconn_complete in the user_app_callbacks structure of the user_callback_config.h header file as follow : .app_on_adv_undirect_complete   = user_app_adv_undirect_complete,
    • changed

.app_on_adv_nonconn_complete   = NULL,

as

.app_on_adv_ nonconn _complete   = user_app_adv_ nonconn _complete,

 

(Like in SDK6.0.4.326, ) 

  1. With the above changes, the system went into

case GAPM_CANCEL:

{

               if(param->status != GAP_ERR-NO-ERROR)

               {

                              ASSERT_ERROR(0);

}

...

}

So had to comment out app_easy_gap_advertise_stop(); in static void adv_data_update_timer_cb()

Then it was continuously transmitting. But still the same problem.

1) The MNF_DATA is not updated, meaning the last two bytes of the raw data was 0000 for a while and update once to 0100 and then remained at that.

[{"timestamp":"2019-06-13T07:14:09Z","type":"Unknown","mac":"80EACA700005","bleName":"","rssi":-39,"rawData":"03030A1811072F2A93A6BDD84152AC0B10992EC6FEED05FFCDAB0100"}]

2) The current consumption is 2.5mA (please see attached picture.)

 

 

PM_Dialog
Offline
Last seen: 10 hours 56 min ago
Staff
Joined: 2018-02-08 11:03
Hi anushiya,

Hi anushiya,

Let me check it and I will get back to you as soon as possible.

Thanks, PM_Dialog

anushiya
Offline
Last seen: 5 hours 2 min ago
Joined: 2017-12-20 02:30
Any update on this please?  

Any update on this please?

 

PM_Dialog
Offline
Last seen: 10 hours 56 min ago
Staff
Joined: 2018-02-08 11:03
Please try the following

Please try the following steps in a clean ble_app_sleepmode example of the SDK.

If you would like to have non connectable advertising, you should do the following:

1. Modify the user_app_adv_start() in order to advertse non-connectable packets

void user_app_adv_start(void)
{
    // Schedule the next advertising data update
    app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb);
    	
	 struct gapm_start_advertise_cmd *cmd = app_easy_gap_non_connectable_advertise_get_active();
    
    // Add manufacturer data to initial advertising or scan response data, if there is enough space
    app_add_ad_struct(cmd, &mnf_data, sizeof(struct mnf_specific_data_ad_structure), 1);

    // Set extended sleep with OTP copy during advertising
    arch_set_extended_sleep(true);

	app_easy_gap_non_connectable_advertise_start();
}

2. In user_callback_config.h, move the user_app_adv_undirect_complete from . app_on_adv_undirect_complete to . app_on_adv_nonconn_complete

static void adv_data_update_timer_cb()
{
    // If mnd_data_index has MSB set, manufacturer data is stored in scan response
    uint8_t *mnf_data_storage = (mnf_data_index & 0x80) ? stored_scan_rsp_data : stored_adv_data;

    // Update manufacturer data
    mnf_data_update();

    // Update the selected fields of the advertising data (manufacturer data)
    memcpy(mnf_data_storage + (mnf_data_index & 0x7F), &mnf_data, sizeof(struct mnf_specific_data_ad_structure));

    // Update advertising data on the fly
    app_easy_gap_update_adv_data(stored_adv_data, stored_adv_data_len, stored_scan_rsp_data, stored_scan_rsp_data_len);
    
    //Remove Stop advertising air operation - a button press will wake-up the system
   // app_easy_gap_advertise_stop();
	
	//Restart the timer -  this line was missing
	app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb);
}

After that, the propriety data of the advertising data, should be updated by 1 every APP_ADV_DATA_UPDATE_TO seconds.

Thanks, PM_Dialog

anushiya
Offline
Last seen: 5 hours 2 min ago
Joined: 2017-12-20 02:30
Thank you for the reply.

Thank you for the reply. Tried this and the MNF_DATA is getting updated. but the smartsnippets still says that consuming 2.5mA ( Keil environment is closed after down loading code). Doesn't that mean that it is not going into sleep mode. I get the same wave pattern attached in my previous message.

PM_Dialog
Offline
Last seen: 10 hours 56 min ago
Staff
Joined: 2018-02-08 11:03
Hi anushiya,

Hi anushiya,

If you found the previous answer useful, please mark it as “accepted”.

Could you please indicate the procedure you followed in order to measure the sleep currents> Be aware that the device goes into sleep mode between the advertising intervals.

Thanks, PM_Dialog

anushiya
Offline
Last seen: 5 hours 2 min ago
Joined: 2017-12-20 02:30
In the solution you provided

In the solution you provided I have a questions:

In step 2, you requested In user_callback_config.h, move the user_app_adv_undirect_complete from . app_on_adv_undirect_complete to . app_on_adv_nonconn_complete.

The actions needed to do when . app_on_adv_undirect_complete and . app_on_adv_nonconn_complete will be different isn't it? I had 

app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb);

inside  user_app_adv_non_connectable_complete funtions and assigned to . app_on_adv_nonconn_complete = user_app_adv_non_connectable_complete and removed it from last line of 

static void adv_data_update_timer_cb()

But that didn't work. May I know why please?

 

In regard to measuring the current I measured using two methods.

1) Using smartsnippets and Hybrid connection (JTAG and com port). (After downloading the code using booter I tried removing the JTAG jumpers from the development board as well). The correct drawn was 0.5mA ( Peack current 5mA and Ave. current 0.5mA)

2) Using the test point TP6 and the corresponding jumper connection to activate the amplifier (expecting the current to be too small). The measurement on the oscilloscope is 100 times of the value received in smart snippets.

If the code is putting the DA14586 into sleep mode, I expect the current to be in uA range.

I downloaded a fresh version of 6.0.10.511, extracted the code and only changed the 3 items you mentioned above.

PM_Dialog
Offline
Last seen: 10 hours 56 min ago
Staff
Joined: 2018-02-08 11:03
Hi anushiya,

Hi anushiya,

The . app_on_adv_undirect_complete and . app_on_adv_nonconn_complete are two completely different callback functions and it depends on the advertising procedure that you are using.

  • The app_on_adv_undirect_complete will be triggered only if undirect advertising is used in your application. Please check the ble_app_sleepmode example of the SDK
  • The . app_on_adv_nonconn_complete will be triggered only if you are using not-connectable advertising

However, both them will be executed if you STOP the advertising procedure

In your case, you are using non-connectable advertising, so if you send a STOP command towards to the BLE stuck, the app_on_adv_nonconn_complete will be executed.

The static void adv_data_update_timer_cb() is the step 3. Can you please clarify what you mean that it does not work? Can you please indicate if the static void adv_data_update_timer_cb() is triggered?

Be aware that if you don’t stop advertising, the device will never go into permanent sleep, but it will go into sleep between the advertising intervals. In order to measure sleep mode currents, the usage of SmartSnippets toolbox is strongly NOT recommended. Please check this tutorial Tutorial 4: Sleep modes current measurement in order to check how you could measure sleep currents.

Thanks, PM_Dialog