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年6个月前
加入: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,

定时器0和2是硬件定时器,因此它们具有生成脉冲宽度调制信号的能力,基于此功能可以产生蜂鸣声。没有选择用App_easy_Timer(软件计时器)替换这两个定时器中的一个

布罗尔,
STS_Dialog.

Ruchi Patel
Offline
Last seen:2年6个月前
加入:2017-03-29 10:50
Dear Dialog_support Team,

Dear Dialog_support Team,

对不起,我已经给了你对timer0,2的错误解释。

我希望我的设备处于睡眠模式,当按下按钮或应用程序没有任何中断时。在设备中断后,Timer0,2应该从睡眠中醒来,完成工作,然后再次睡觉。我不想在睡眠期间运行Timer0,2。所以有可能吗?

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年6个月前
加入:2017-03-29 10:50
Dear Dialog_support Team,

Dear Dialog_support Team,

感谢您的答复。我根据您的建议配置了我的设备。现在我想知道,在睡眠模式下可以广告可以广告吗?如果是,则在代码中,如果从按钮或app没有任何中断,则将睡眠模式函数(API)。

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年6个月前
加入:2017-03-29 10:50
Dear Dialog_Support Team,

Dear Dialog_Support Team,

Thank you for your quick reply.

1.您能否指导我,如果我的设备处于扩展睡眠模式和设备应始终广告。是否可以?如果设备始终广告,则功耗如何?

我正在使用加速度计传感器。传感器通过I2C与DA14580通信。每当有移动时,加速度计会导致控制器中断。理想情况下,控制器应从睡眠模式中唤醒,但在扩展睡眠模式下,控制器未接收来自加速度计的任何类型的中断。其在完全活动模式下工作正常。

3.当我按下按钮时,设备从睡眠模式唤醒,然后立即再次进入睡眠模式。由于此,我的蜂鸣器音没有正常工作。蜂鸣器戒指非常快。如何增加唤醒时间或者我想完成我的任务然后在任务结束时,设备再次进入睡眠模式。

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)是的,存在是睡眠模式,并且可以唤醒广告,设备的电源增量取决于设备的广告频率(意味着唤醒和发送广告包的频率)。所以它取决于广告间隔,并且功耗的值不是固定的,你唤醒了你的功率越多。

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)由于设备将通过外部中断唤醒它将检查是否有任何未决的BLE事件,如果没有任何情况,那么设备将重新睡眠,以防止设备返回睡眠状态,您可以刚刚调用ARCH_DISABLE_SLEEP()并保留设备唤醒,当它的时间返回睡眠时,您可以调用ARCH_SET_EXTEDDED_SLEEP()另一种方式是留下睡眠状态并防止设备往往通过在app_on_ble_powered()中应用一些自定义代码或在app_on_system_powered()回调中休眠,并在条件上返回Keep_powered(以防止设备进入睡眠)或Goto_Sleep(允许设备进入睡眠)。因此,只要您希望蜂鸣器响起,您可以保持设备唤醒,随时随地睡觉。

Thanks MT_dialog

Ruchi Patel
Offline
Last seen:2年6个月前
加入: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年6个月前
加入: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