Hi Dialog Team,
I am working on a custom board with the 'ble_app_nonconn' example in the misc folder in SDk folder. My project requirement is as follows.
- Go to sleep mode (ARCH_EXT_SLEEP_ON) whenever no ble or other activity.
- When external sensor gives data, dialog chip will wakeup on pin change interrupt and start decoding the data from the sensor using timer 0.
- Decode the data and update it on the advertisement string.
- 开始广告使用“user_app_adv_start()的一个d start an easy timer that will expire in 6 seconds. Till then the advertisement data is advertised. When app_easy timer expires, stop the advertisement using 'app_easy_gap_advertise_stop()' and this will put the chip to sleep.
- Before stopping advertisement, the wakeup pin will be enabled to wake up the chip from sleep when the next data is ready.
I have mananged to complete the above steps in debugging mode. When I run my program on the RAM and disconnect the debugger the current consumption reduces to 2.4µA. When the external interrupt occurs the current rises to around 50µA and oscillates between 2.4µA to 50µA. ( I guess this is due to the sleep between advertising internvals). So I think the above concept works fine.
But I am stuck at two problems.
1) During sleep mode ( debugger disconnected condition ) when my chip advertises I think it advertises only once. Because I am checking it on a BLE scanner app and I notice that the RSSI value is updated only once. It it only transmitiing once?. If it is transmitting once, then why the current oscillation between 2.4µA to 50µA for the 6 sec duration?
2) The above condition works for a while and all of a sudden, the current increases to 350µA and then there is no advertisement at all. Is my program halted?
Please note that the above two condition occurs only when I disconnect the debugger.
What could cause these two issues during sleep?
Regards,
Mark


Hi Mark,
When performing any kind of measurements in sleep mode, you should not run the firmware in debug mode. Otherwise, the device fails to go into sleep mode and the power consumption will be dramatically increased. To do so, my suggestion would be to have the debugger de-attached, as this prevents the system to sleep. Additionally, a very important tip is that in case you are using SPI Flash in your custom board, you should power it down.
Can you please try to debug it furthermore? Please run it in debug mode - power consumption is not important in this step. You mentioned that is advertising once… After the first advertising what does the fw do? The WDOG is enabled or disabled? I would suggest you to have it enabled, otherwise you will not be notified if the fw stucks somewhere. If you are completely sure that the fw is running as expected (no WDOG occurred or NMI), please use the Power Profiler of SmartSnippets Toolbox to check that it is not advertising once.
Thanks, PM_Dialog
HI PM_Dialog,
When running in debug mode, the code advertises properly and the firmware does not get stuck anywhere. I ran the code in debug mode for more than an hour and it works fine. When I disconnect the debugger and run it, the problem ( as mentioned in the first post) occurs.
I do have another doubt. Does your example code 'ble_app_nonconn' in the 'misc' folder support extended sleep mode?. Because it works properly when connected in debugging mode. But when i disconnect the debugger the problem starts.
I am advertising for 6 seconds and stopping it. But it advertises only once and but there is an oscillation in current consumption during the whole 6 seconds. That means that it is waking up between advertising intervals but why no packets are being transmitted. ?
Regards,
Mark
Hi Mark,
The ble_app_nonconn project of the SDK6.0.12 does not support sleep mode by default. However, you can change the sleep mode configuration. Since it’s a custom code and custom board, would it be possible to share the changes you have done in order to configure it in sleep mode? Another option to start investigating which is the route cause might be to start toggling a GPIO or printing some debugging messages, as the firmware gests stuck only in non-debug mode. In debug mode, I assume that you have the WDOG enabled..
Thanks, PM_Dialog
Hi PM_Dialog,
My firmware doesnt get stuck. It transmits only a single advertisement for the entire 6 second duration. But in debug mode it transmits 4 to 5 times for the 6 second duration. Why does it transmit only once in non-debug mode?. Is the sleep mode affecting the ble advertisement?.
For sleep mode i have made the following changes.
I stopped the advertisement after 6 seconds and my chip goes into extended sleep.
Regards,
Mark
Hi Mark,
Not sure what happen since it is a custom board/code. Can you please use the arch_printf() in the user_app_adv_start() and in the user_app_adv_nonconn_complete()? Also, can you please send me a screenshot from the Power Profiler? When the debugger is attached and de-attached.
Thanks, PM_Dialog
Hi ,
I dont have an option to print messages in my custom board. I am using a multimeter to measure the current consumption.
我认为问题在于调用user_app_adv_start() function when i am ready to advertise again.
I have attached the code below for your refernce.
Hi PM_Dialog,
As u suggested, i pulled down a GPIO onperiph_init()and pulled it high before going to sleep beforearch_goto_sleep(sleep_mode)in arch_main.c. I attached the screenshot of oscilloscope output. The problem I am facing is, when I call user_app_adv_start(), the chip is transmitting the data only once. I confirmed this by looking at the RSSI value on the BLE scanner app in android. I have attached the sample code also.
As I have an urgent demonstration of my product, I have changed the advertising interval to 200ms and somehow managing to advertise the data by calling 'user_app_adv_start()' and after 1 second I am stopping it and in the advertise complete function I am calling 'user_app_adv_start()' again. I am repeating these steps for 6 seconds and I am getting multpile advertising hits in my app. Each time when I call 'user_app_adv_start()' I get only 1 hit in my app until I stop the advertisement and call it again.
Why does 'user_app_adv_start()' advertising the data only once?
你能请分享我一个信标dat的示例代码吗a which wakes up on an external interrupt and modifies the advertising string and transmits it and goes to sleep.
Regards,
Mark
Hi Mark,
Let me check it and I'll get back to you.
Thanks, PM_Dialog
Hi Mark,
The arch_main.c is SDK file and it is highly recommend NOT modifying any SDK file. All the modifications should be done in the application layer, in the filed that start with user_ . All the other files as SDK related and if any of them is modified we cannot guarantee that the application will work correctly. The SDK should be used as it is provided by dialog without any other modification.
Regarding you source code I am not able to compile it as I am getting couple of errors. Please see below a diff file for how to stop non-connectable advertising, put the device in sleep mode and wake it up. My recommendation would be to start with ble_app_sleepmode example of the SDK which contains advertising data update as well. How you would like to build the application and how to update the beacon data is up to you. Please follow the steps in the ble_app_sleepmode example of the SDK.
Thanks, PM_Dialog
Hi PM_Dialog,
1) What kind of errors are u getting when u compile my code?.
2) I modified your arch_main.c file because, when my sensor sends an interrupt I have to wait around 20ms for getting the data, but if I dont wait my code will go back into sleep and I will miss the data. That's why I modified the arch_main.c file to wait till I get the data out and then put the chip to sleep. How to prolong the wake time of the chip?. Can you suggest an idea for that?.
3) When I start my advertising, most of the code content that I added to arch_main.c will not execute because I am checking for conditions in the main loop and I will not execute it while I am advertising. Why is that affecting your sdk and advertising sequences?.
4) When I get an interrupt until I process the data from my sensor I will not start advertising. After I get the data I will start the advertising and I am sure none of my code will run during advertising. So why does that give any problem to the sdk?.
Thanks,
Mark
Hi PM_Dialog,
Please support me on the above points. As you suggested I have started working on the sleepmode project in ble_examples. My biggest doubt is when my external sensor gives an interrupt and gives the data only after 20ms, how do I have to prevent the chip from going into sleep for that 20ms after I had woken up from sleep.
Regards,
Mark
Hi Mark,
Please find attached a log file with the errors from the Keil IDE. It would be very helpful to indicate the SDK version that you are using. Not sure about the SDK version but we strongly recommend using the latest version (SDK6.0.12).
Thanks, PM_Dialog
Hi PM_Dialog,
The issue got sorted out after we added the external 32Khz crystal oscillator.
It seems that that the ble_app_sleepmode code is unstable without the 32Khz crystal. But your datasheets say that this 32Khz is optional which is very much misleading. Please correct the datasheets or it may mislead others too. I have spent 3-4 months on this issue and had no clue it was due to the external crystal.
Any way, thank you for your online support.
Regards,
Mark
Hi Mark,
很高兴你找到了工作。这是铁饼sed over our previous conference calls. Thanks for your indication too.
问候,pm_dialog