Can we replace Timer0 and Timer2 by app_easy_timer?

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
12 posts / 0 new
Last post
Ruchi Patel
Offline
Last seen:2 years 6 months ago
加入:2017-03-29 10:50
Can we replace Timer0 and Timer2 by app_easy_timer?

Dear Dialog_support Team,

I was using Timer0 and Timer2 in my application to play buzzer sound and to calculate push button pressed time. Now i want to add sleep modes in my application and after adding extended sleep mode, timers are not working properly. I have also read different Dialog's forum posts that Timer0 and Timer2 will not work with sleep modes. So can i replace both timers by app_easy_timer? And i have configured duty cycles in Timer0,2 to play buzzer sounds. So how to set duty cycle using app_easy_timer?

Thanks and Regards,
Ruchi Patel

Device:
STS_Dialog (not verified)
Hi Ruchi Patel,

Hi Ruchi Patel,

The timers 0 and 2 are hardware timers so they have he ability of generating Pulse Width Modulated signals, based on this capability you can produce buzzer sounds. There isn't the option to replace one of these two timers with app_easy_timer(software timer)

BR,
STS_Dialog.

Ruchi Patel
Offline
Last seen:2 years 6 months ago
加入:2017-03-29 10:50
Dear Dialog_support Team,

Dear Dialog_support Team,

对不起,我给了你错误的解释有关Timer0,2.

I want my device is in sleep mode, when there is no any interrupt from push button or App. And after device gets interrupted, Timer0,2 should awake from sleep, do its work and then again go to sleep. I don't want to run the Timer0,2 during sleep. So is it possible?

Can you suggest me any good and relevant example of extended sleep mode?

Thank you in advance.

With regards,
Ruchi Patel

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi Ruchi Patel,

Hi Ruchi Patel,

大部分的例子运行在延长睡眠mode, if you would like an example that would run with a press of a button, for example be in sleep mode and as soon as the button is pressed or an interrupt occurs the device would wake up you can check the ble_app_sleepmode, the original configuration is for deep sleep but you can easily change that by changing the app_default_sleep_mode from ARCH_DEEP_SLEEP_ON to ARCH_EXT_SLEEP_ON and by changing the memory configuration to CFG_MEM_MAP_EXT_SLEEP. After doing that you can set up the timer in order to generate the pwm and disable the sleep in runtime as long as you would like the device to generate the PWM, as soon as you are ready to go to sleep, disable the timers and set back the sleep mode to exteded (in order to change the sleep modes during runtime you can use arch_disable_sleep() and arch_set_exteded_sleep()).

Thanks MT_dialog

Ruchi Patel
Offline
Last seen:2 years 6 months ago
加入:2017-03-29 10:50
Dear Dialog_support Team,

Dear Dialog_support Team,

Thank you for the reply. I have configured my device as per your suggestion. Now i want to know that, can advertising is possible during sleep mode? If yes then in code, where to put sleep mode function (api) if there is no any interrupt from push button or app.

Thanks and Regards,
Ruchi Patel

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi Ruchi Patel,

Hi Ruchi Patel,

当睡眠模式启用它意味着德维克e is capable of advertising and sleeping in between the advertising or the connection periods, when the device doesn't implement sleep it means that the device will stay awake even if there is no BLE activity. So in short, the when the 580 is in sleep mode it will wake up advertise and go back to sleep automatically. Regarding the question "where to put the sleep mode function (api)" i dont quite get it, apparently you would like to enable the PWM and keep the device awake for a certain period between two events, one that it will trigger the PWM event and one that will end the PWM and send the device back in sleep mode, so when the event is triggered you will disable the sleep and start the timer in PWM mode and when its over you will disable the PWM and send the device back to sleep.

Thanks MT_dialog

Ruchi Patel
Offline
Last seen:2 years 6 months ago
加入:2017-03-29 10:50
Dear Dialog_Support Team,

Dear Dialog_Support Team,

Thank you for your quick reply.

1. Can you please guide me that, if my device is in extended sleep mode and device should always advertising. Is it possible? What about power consumption if device is always advertising?

2. I am working with accelerometer sensor. Sensor communicates with DA14580 via I2C. Whenever there is movement, accelerometer gives interrupt to the controller. Ideally controller should awake from sleep mode but controller not receiving any kind of interrupt from accelerometer during extended sleep mode. And its working fine in fully active mode.

3. As i press push button, device wakes up from sleep mode and then immediately it goes to sleep mode again. Due to this, my buzzer tone is not working properly. Buzzer rings very fast. How to increase wake up time or i want to finish my task then at the end of task, device goes to sleep mode again.

With Regards,
Ruchi Patel

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi Ruchi Patel,

Hi Ruchi Patel,

1) Yes, being is sleep mode and wake up for advertising is possible, the power cosnumption of the device depends on how often the device is advertising (meaning how often is going to wake up and send an advertising packet). So it depends on the advertising interval and the value for the power consumption is not fixed, the more you wake up the more power you consume.

2) In order to wake up from sleep you will have to configure the wake up timer, that means that you will have to configure the wake up module of the 580 in order to wake up from an external interrupt, while the device is in sleep mode. You can check the ble_app_sleepmode project where the device wakes up from an external interrupt emulated via a button press. After you are awake, then you can perform whatever actions you would like, advertise or read the accelerometer etc. If you have configured the wake up timer properly and the device still doesn't wake up, then you should check the pollarity of the wake up signal, perhaps the debouncing that you have set etc.

3) Since the device will wake up via an external interrupt it will check if there are any pending BLE events and if there aren't any, then the device will go back to sleep, in order to prevent the device from going back to sleep, you can just invoke the arch_disable_sleep() and keep the device awake, when its time to go back to sleep you can invoke the arch_set_extended_sleep() also another way of doing that is to leave the sleeping state as is and prevent the device from going to sleep via applying some custom code in the app_on_ble_powered() or in the app_on_system_powered() callbacks and return conditionally either KEEP_POWERED (in order to prevent the device from going to sleep) or GOTO_SLEEP (allowing the device to go to sleep). So you can keep the device awake as long as you would like the buzzer to ring and go to sleep whenever you are ready.

Thanks MT_dialog

Ruchi Patel
Offline
Last seen:2 years 6 months ago
加入:2017-03-29 10:50
Dear Dialog_support,

Dear Dialog_support,

Thank you for your reply.

1) I understand this point. I have implemented this in my application code. I want my device to do advertising even when it is in sleep mode. So its successfully implemented.

2) I have implemented external interrupt same as ble_app_sleepmode example. But in my custom application, there is 3 different functionalities are implemented using single push button. For example, If push button is pressed for 3 times then functionality 'A' will run, if push button is long pressed for 3 seconds then functionality 'B' will run, if push button is pressed for 5 times then functionality 'C' will run. But i can generate external interrupt wake up for one functionality only although i wrote a code for 3 functionalities. Can you please help me out for this? Can you explain me more about how polarity and debouncing affect to sleep and wake up functionality.

3) Yes i have used these 2 functions arch_disable_sleep() and arch_set_extended_sleep() to wake up the device and to put the device is in sleep mode.

Thank you again for your helpful reply. I am facing one issue. Whenever mobile application tries to connect to device(when device is in sleep mode and its advertising), device is not getting connected smoothly, means its taking long time to connect and sometimes it shows message like connection fail, disconnected. I mean its not working smoothly in sleep mode as it was working smoothly in active mode. What could be the reason for that? I have also configured that, whenever app connects to the device, device should wake up from sleep and then go back to sleep whenever device disconnects from app.

With Regards,
Ruchi Patel

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi Ruchi Patel,

Hi Ruchi Patel,

Regarding the second question, sorry, i am not able to understand the question, yes you can implement a functionallity where you can track the time that a button is pressed, but from the previous post i understood that the device is not able to wake up via an interrupt from a sesnor, so what i can assume is that perhaps this has something to do either with the pollarity that the wake up timer has to track or due to the debouncing feature that the wakeup timer implements. You will be able to find more info regarding these settings in the UM-B-051 DA1458x Software Platform Refence.pdf in the drivers section paragraph 10.7 Wake-Up Timer.

There is no difference between the sleep mode and always active mode regarding the connection procedure of a device, i mean that the central will be waiting for an advertising event in order to start the connection procedure, and the device, either when sleeping or when its not, will advertise in fixed connection intervals, what can delay the connection procedure is the fact that the advertising interval is large and this is irrellevant with the sleeping mode. I would recommend to run some dialog examples in sleep mode and then try again without the sleep mode, and check if you can replicate your issue having those examples as reference.

Thanks MT_dialog

Ruchi Patel
Offline
Last seen:2 years 6 months ago
加入:2017-03-29 10:50
Dear Dialog_support,

Dear Dialog_support,

Thank you for your constant support. Now i am able to wake up the from the sleep using sensor interrupt. After configuring extended sleep mode, i have noticed that my custom application is not working smoothly as it was before. The issues i am facing are,
1. Smartphone's App is not getting connected easily with board (development kit or custom board). It shows status like "connecting", "connection fail", "Disconnected".
2. There is one push button used for my custom application. And i have configured that as i press push button, device should wake up from the sleep. But sometime after pressing push button, device is not waking up.

With Regards,
Ruchi Patel

MT_dialog
Offline
Last seen:2 months 2 weeks ago
Staff
加入:2015-06-08 11:34
Hi Ruchi Patel,

Hi Ruchi Patel,

Since your previous issue has been answered, please dont post additional questions in irrelevant forum topics, you can always create a new topic for your question.

  1. The fact that is difficult to connect might be related with a number of factors, and from your description i am not able to determine what could be the issue. The connection procedure regarding the peripheral side is mostly related with the advertising, if the device is advertising and the central is able to see the device it will need two advertising events in order for the connection procedure to initiate. What can slow down the connection procedure is the advertising interval, the less frequent the device is advertising the more it will take for the peripheral to connect with the central. Also that can relate with the phone or with the phone application itself, and in no case with the fact that you 've implemented an external wake up or a wake up via a timer.
  2. Regarding your second question, you will have to debug this in order to figure out why that happens, check if the interrupt occurs everytime your press the button, there might be a condition to your code that prevent the start advertise command send to the stack, if the interrupt doesn't occur, check if the wake up timer is always configured properly (same polarity and debouncing configuration), also if this occurs on your custom board that might be related with the hw.

Thanks MT_dialog