Learn MoreFAQsTutorials

9 posts / 0 new
Last post
Rajapurerohit
Offline
最后一次露面:4 months 3 weeks ago
加入:2017-04-20 09:17
睡眠模式配置

Dear Dialog_Support,

We are developing application where we are going to wake up device using two interrupt method.
1.使用按钮中断
2. Sensor interrupt [If any activity on sensor interrupt pin]

我已经提到了BLE_SLEEP_MODE示例,但对于我的应用程序,它无法正常工作。
I have used following snippet to config interrupt,

static void app_button_press_cb(void)
{
arch_disable_sleep();
//arch_force_active_mode();
if (GetBits16(SYS_STAT_REG, PER_IS_DOWN))
{
periph_init();
}

if (arch_ble_ext_wakeup_get())
{
arch_set_sleep_mode(app_default_sleep_mode);
arch_ble_force_wakeup();
arch_ble_ext_wakeup_off();
app_easy_wakeup();
}
}

void app_button_enable(void)
{
app_easy_wakeup_set(app_wakeup_cb);
wkupct_register_callback(app_button_press_cb);
wkupct_enable_irq(WKUPCT_PIN_SELECT(GPIO_KEY_PORT, GPIO_KEY_PIN) | WKUPCT_PIN_SELECT(GPIO_I2C_BUZZER_PORT, ACCELEROMETER_INT), // select pin (GPIO_PORT_1, GPIO_PIN_1)
wkupct_pin_polarity(gpio_key_port,gpio_key_pin,wkupct_pin_polarity_low)|wkupct_pin_polarity(gpio_i2c_buzzer_port,Accelerometer_Int,WKUPCT_PIN_POLARITY_LOW),//极性低
1 / / 1 event
40);// debouncing time = 0

}

void user_app_add_undirect_complete(uint8_t状态)
{
//禁用BLE和TIMER事件的唤醒。只有外部(GPIO)唤醒事件可以唤醒处理器。
如果状态= = GAP_ERR_CANCELED)
{
user_app_adv_start();

// Configure wakeup button
app_button_enable();
}
}

使用此,我无法生成中断并从睡眠中唤醒我的设备。
Some random behavior is happening, like only first time i am able to detect push button interrupt and if repeat for 2nd time fail to detect.
Same with sensor interrupt.
请帮我解决问题。

Thanks and Regards
rohit.

关键词:
Device:
PM_DIALOG.
Offline
最后一次露面:6 days 17 hours ago
Staff
加入:2018-02-08 11:03
嗨rajapurerohit,

嗨rajapurerohit,

您能否澄清您想要与您的申请有关的?As I can see in your code that you have posted, you call user_app_adv_start() into user_app_adv_undirect_complete() function, so when the advertise is completed (cancelled by your application) you will start advertise again and your device won’t go to sleep mode. So can you please explain what exactly you would like to do? For example you would like to advertise and have the wake up interrupt configured while advertising?
A few reasons why the waking up might fail:
•在user_app_adv_undirect_complete()函数中,您不会调用ARCH_BLE_EXT_WAKEUP_ON()函数,作为SDK的BLE_APP_SLEEPMODE示例。当广告完成时,此函数将Sleep_ext_Force变量变为True,这是默认为false。当按按钮触发APP_BUTTON_PRESS_CB()函数时,ARCH_BLE_EXT_WAKEUP_GET()返回默认值为false,因此代码进入if(ARCH_BLE_EXT_WAKEUP_GET())不会执行。所以,我建议检查一下。
• Also, you should check the state of your wake up pins and make sure that they are both high (since you have configured the wake up to be triggered when low). Since if one of the two sources remain in interrupt state (low in your case) then the wake up controller won’t be triggered when the other interrupt toggles low.
• In addition, do you enable your button into your application code, the second time? If it’s enabled once, only the first time you will be able to detect the push button interrupt. So do you invoke the app_button_enable() before you would like to wake up from an external interrupt?

谢谢pm_dialog.

Rajapurerohit
Offline
最后一次露面:4 months 3 weeks ago
加入:2017-04-20 09:17
Hello PM_Dialog,

Hello PM_Dialog,

Thank you for the response.
我的要求是,
1.Configure device in extended_sleep mode and wake up when there is interrupt from button, sensor interrupt and if we write into characteristic after connection.
2. Is it possible to sleep while advertising and connection ?
Secondly want to set device in sleep during advertising but it should display on my mobile application even though it is in sleep.
And sleep if mobile application connects. Is it possible? if yes, which algorithm should i follow .

3.Algorithm implemented right now is wake up device whenever there is button or sensor interrupt but not able to wake up device when there is button interrupt and i have attached code snippet in my previous comment.

GPIO Configuration is as follows
gpio_configurepin(gpio_key_port,gpio_key_pin,input_pullup,pid_gpio,false);
GPIO_EnableIRQ(GPIO_KEY_PORT, GPIO_KEY_PIN, GPIO3_IRQn, true, true, 250);
gpio_registercallback(gpio3_irqn,pushbuttoninterrupthandler);

GPIO_ConfigurePin(GPIO_SENSOR_PORT, SENSOR_INT, INPUT_PULLDOWN, PID_GPIO, false);
GPIO_EnableIRQ(GPIO_SENSOR_PORT, SENSOR_INT, GPIO2_IRQn, false, true, 250);
gpio_registercallback(gpio2_irqn,sensorinterrupthandler);

Thanks and Regards
rohit.

PM_DIALOG.
Offline
最后一次露面:6 days 17 hours ago
Staff
加入:2018-02-08 11:03
嗨rajapurerohit,

嗨rajapurerohit,

1,2)设备在广告和连接间隔之间睡眠。设备可以从预编程的BLE事件(广告事件或连接事件或内核定时器)或唤醒中断时唤醒。例如,在广告案例中,设备将唤醒广告,并将再次返回睡眠状态,直到下一个广告间隔时间经过时间。我无法获得你的意思,即使在手机上应该在手机上显示,即使它在睡眠状态。你能澄清你的问题吗?

3) In the configuration you have posted in your last post, you have configured an interrupt on a GPIO. This interrupt will be executed only when your device is woken up and it is advertising. This configuration isn’t able to wake up the device during sleep, the wake up controller should be used when the device is into sleep mode, in order for an external interrupt to wake it up.

Thanks PM_dialog

PM_DIALOG.
Offline
最后一次露面:6 days 17 hours ago
Staff
加入:2018-02-08 11:03
You will have to understand

You will have to understand how the device operates, the device is going to wake up and advertising according to the advertising interval, so you can either place the device in permanent sleep and wake up only via a push button or a kernel timer or you can set a standard advertising interval so that the device will wake up automatically (the latter is the only way to be discoverable from a central). I've also mentioned a few things that you didn't follow in the code implementation that you have attached:

1. You enable the standard IRQs in the set_pad_functions and in the callbacks you are also mixed up with the wake up interrupt, when you are in sleep mode regarding permanent or wake up automatically those simple gpio interrupts won’t be able to wake up the system, the system wakes up when sleep via the wake up interrupt. Those interrupts will only work while the system is always on.

2.此外,在调用Timer App_addata_update_timer_used之后,调用您调用停止广告,然后您重新启动广告,然后启动唤醒中断,并且您也可以启用错误(传递错误的参数),因为您已将PIN参数混淆使用极性参数(请检查函数接受或查看此论坛票证的参数https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bl...). Additionally when the interrupt occurs from the external source you send a start advertising command while you are still advertising, but you won’t be able to do that ever since you are checking arch_ble_ext_wakeup_get() which will always will return flash since you have never enabled the arch_ble_ext_wakeup_on() (which is something that I’ve already mentioned in previous post).

要得出结论,我无法弄清楚你附加的代码应该做的代码,或者你想做什么,我建议看看BLE_APP_SLEEPMODE示例并试图了解系统如何运行。

Thanks PM_dialog

Rajapurerohit
Offline
最后一次露面:4 months 3 weeks ago
加入:2017-04-20 09:17
Hi PM_dialog,

Hi PM_dialog,
Thank you for the response.

But i am unable to understand wkupct_enable_irq (); how does it work and what polarity.
在数据表中也没有多少解释。你能告诉我两个中断针灸配置的例子吗?
From attached link also i am not able to clear my pins interrupt.
如果遵循睡眠模式示例配置,我无法检测到两个中断或只有一个中断第二个不起作用。
Please help me to solve issue.

Thanks and Regards
rohit.

PM_DIALOG.
Offline
最后一次露面:6 days 17 hours ago
Staff
加入:2018-02-08 11:03
嗨rajapurerohit,

嗨rajapurerohit,

I have modified the ble_app_sleepmode example of SDK5.0.4 in order to provide you an example of two interrupt pins configuration. In this example, you are able to wake up your device either with SW2 (GPIO0_6) button2 or with SW3 (GPIO1_1) button, using the DA1458x ProDK. The device advertises for a defined amount of time (APP_ADV_DATA_UPDATE_TO) when it’s powered up. The default value is 10 seconds. After the expiration of the above timeout, and if the device does not enter the connected state, it stops advertising. After that, the device does nothing and waits for an external event to exit the sleeping state. You can wake up the device by pressing one of the two buttons I’ve just referred you. After the button press the device will start to advertise again for the predefined time. You can modify the ble_app_sleepmode example by following the below steps.

1) Define the SW2 (GPIO0_6) button2 in user_periph_setup.h into HW_CONFIG_PRO_DK configuration
#define GPIO_BUTTON_2_PORT GPIO_PORT_0
#define GPIO_BUTTON_2_PIN GPIO_PIN_6

2)保留按钮2。到达user_periph_setup.c文件并添加到gpio_reservations()函数以下代码:

保留_GPIO(PUSH_BUTTON,GPIO_BUTTON_2_PORT,GPIO_BUTTON_2_PIN,PID_GPIO);

3) Go to the user_periph_setup.c and add in the set_pad_functions() function the following code:

GPIO_ConfigurePin(GPIO_BUTTON_2_PORT, GPIO_BUTTON_2_PIN, INPUT_PULLUP, PID_GPIO, false);

4)在sleep_mode.c中,用以下函数替换app_button_enable()函数。以下函数将两个按钮设置为唤醒中断。

static void app_button_enable(void)
{
app_easy_wakeup_set(app_wakeup_cb);
wkupct_register_callback(app_button_press_cb);
wkupct_enable_irq(wkupct_pin_plect(gpio_button_port,gpio_button_pin)| wkupct_pin_select(gpio_button_2_port,gpio_button_2_pin),//选择pin(gpio_button_port,gpio_button_pin)
WKUPCT_PIN_POLARITY(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW) | WKUPCT_PIN_POLARITY(GPIO_BUTTON_2_PORT, GPIO_BUTTON_2_PIN, WKUPCT_PIN_POLARITY_LOW), // polarity low
1 / / 1 event
40);// debouncing time = 0
}

如果您遵循以下步骤,则必须能够使用两个中断引脚配置并使用其中任何一个唤醒您的设备。此外,我建议您再次检查申请中醒来的三种可能的原因可能会失败。

Thanks PM_dialog

Rajapurerohit
Offline
最后一次露面:4 months 3 weeks ago
加入:2017-04-20 09:17
Hello PM_dialog,

Hello PM_dialog,
Thank you for the response,
我有更改的功能,对我来说很好。
基本上我的最终目标是追随部分
1.在按下开关后醒来并在6秒后返回睡眠,如果未按下按钮
(motion detected) again
2. Be awake after motion was detected and go back to sleep after 6 seconds if motion is not
detected (switch pressed)again
3.在收到连接状态时醒来,需要嗡嗡声。然后回去
to sleep after 6 seconds if motion is not detected (switch pressed)again

And i am using timer0 and timer 2 for pwm generation. but in if write above mentioned flow then m not able to connect device properly and pwm also not working properly as it is always going to sleep state.
Can you please help me to use timer for wake up and goto sleep after 6sec

Thanks and Regards
rohit.

PM_DIALOG.
Offline
最后一次露面:6 days 17 hours ago
Staff
加入:2018-02-08 11:03
嗨rajapurerohit,

嗨rajapurerohit,

1、2),我能理解,你想叫醒你p either via a switch button interrupt or via a sensor interrupt and advertise for 6 seconds. After 6 seconds the device should go to sleep and wake up via the next interrupt. Did I understand correctly? In case you want to do that, you should modify the inputs of the wkupct_enable_irq() function in app_button_enable() function. In the example that I have posted, the wkupct_enable_irq() function enable the interrupt GPIO and the polarity of the two buttons. In your case, you should modify the wkupct_enable_irq() as :

wkupct_enable_irq(WKUPCT_PIN_SELECT(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN) | WKUPCT_PIN_SELECT(GPIO_SENSOR_PORT, GPIO_SENSOR_PIN), // select pin (GPIO_BUTTON_PORT, GPIO_BUTTON_PIN)
WKUPCT_PIN_POLARITY(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW) | WKUPCT_PIN_POLARITY(GPIO_SENSOR_PORT, GPIO_SENSOR_PIN, WKUPCT_PIN_POLARITY_LOW), // polarity low
1 / / 1 event
40);// debouncing time = 0

The GPIO_SENSOR_PORT and GPIO_SENSOR_PIN are for example. In your application you should make as input your GPIO sensor definitions. In order to advertise for 6 seconds when you wake up you should change the value of the advertising data time. Please go to the user_sleepmode.h file and change the value of APP_ADV_DATA_UPDATE_TO definition to 600. Also, I suggest you to check the polarity of your sensor in order to catch the interrupt and trigger the wakeup controller. For example, if the polarity of the sensor is low and you configure the polarity of wake up controller low, the interrupt will not be caught and the wake up controller will not be triggered. The example that I have provided in the previous post sets up a wake up signal from two sources, you can use that and replace the button with the interrupt using the polarity of your sensor.

3) As I have already mentioned in a previous post, when the device is in extended sleep mode you can only wake up from BLE events, when in connection you will wake up and sleep depending on the predefined connection intervals that you have arranged with you master, you can’t just go to permanent sleep for 6 seconds and still be able to maintain a connection. Regarding the timers, when in extended sleep the device will shut down all the peripherals, you are not going to be able to operate with PWM while you are in sleep. Please try to understand how BLE operates.

https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bl...

Thanks PM_dialog