亲爱的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,
静态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_plect(gpio_key_port,gpio_key_pin)| wkupct_pin_select(gpio_i2c_buzzer_port,Accelerometer_int),//选择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();
//配置唤醒按钮
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.
请帮我解决问题。
谢谢并恭祝安康
rohit.
嗨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?
醒来可能失败的几个原因:
•在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.
你好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 ?
其次,希望在广告期间在睡眠中设置设备,但它应该在我的移动应用程序上显示,即使它在睡眠状态。
如果移动应用程序连接,则睡眠。可能吗?如果是,我应该遵循哪种算法。
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配置如下
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);
谢谢并恭祝安康
rohit.
嗨rajapurerohit,
1,2)设备在广告和连接间隔之间睡眠。设备可以从预编程的BLE事件(广告事件或连接事件或内核定时器)或唤醒中断时唤醒。例如,在广告案例中,设备将唤醒广告,并将再次返回睡眠状态,直到下一个广告间隔时间经过时间。我无法获得你的意思,即使在手机上应该在手机上显示,即使它在睡眠状态。你能澄清你的问题吗?
3)在您在上一篇文章中发布的配置中,您已在GPIO上配置了中断。此中断将仅在您的设备唤醒时执行,并且它是广告。此配置无法在睡眠期间唤醒设备,当设备进入睡眠模式时,应使用唤醒控制器,以便外部中断唤醒它。
谢谢pm_dialog.
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-semicondiondiondum/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示例并试图了解系统如何运行。
谢谢pm_dialog.
Hi PM_dialog,
Thank you for the response.
但我无法理解wkupct_enable_irq();它是如何工作和什么极性。
在数据表中也没有多少解释。你能告诉我两个中断针灸配置的例子吗?
From attached link also i am not able to clear my pins interrupt.
如果遵循睡眠模式示例配置,我无法检测到两个中断或只有一个中断第二个不起作用。
请帮我解决问题。
谢谢并恭祝安康
rohit.
嗨rajapurerohit,
我已经修改了SDK5.0.4的BLE_APP_SLEEPMODE示例,以便为您提供两个中断引脚配置的示例。在此示例中,您可以使用DA1458x Prodk使用SW2(GPIO0_6)按钮2或使用SW3(GPIO1_1)按钮唤醒您的设备。设备通电时,该设备已广告已定义的时间(App_add_data_update_to)。默认值为10秒。在上述超时到期后,如果设备未进入连接状态,则会停止广告。之后,该设备无能为力并等待外部事件以退出睡眠状态。您可以通过按我刚刚提到您的两个按钮之一唤醒设备。按钮按下设备后,将开始再次通告预定义的时间。您可以按照以下步骤修改BLE_APP_SLEEPMODE示例。
1)将user_periph_setup.h中的sw2(gpio0_6)按钮2定义为hw_config_pro_dk配置
#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),//极性低
1 / / 1 event
40);// debouncing time = 0
}
如果您遵循以下步骤,则必须能够使用两个中断引脚配置并使用其中任何一个唤醒您的设备。此外,我建议您再次检查申请中醒来的三种可能的原因可能会失败。
谢谢pm_dialog.
Hello PM_dialog,
Thank you for the response,
我有更改的功能,对我来说很好。
基本上我的最终目标是追随部分
1.在按下开关后醒来并在6秒后返回睡眠,如果未按下按钮
(检测到的运动)再次
2.在检测到运动后醒来,6秒后恢复睡眠,如果动作不是
detected (switch pressed)again
3.在收到连接状态时醒来,需要嗡嗡声。然后回去
6秒后睡觉,如果没有检测到动作(切换)再次
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
谢谢并恭祝安康
rohit.
嗨rajapurerohit,
1,2)由于我能够理解,您希望通过交换机按钮中断或通过传感器中断醒来,并通过传感器中断并宣传6秒。6秒后,设备应睡觉并通过下一个中断唤醒。我明白了吗?如果您想要这样做,则应在App_Button_Enable()函数中修改WKUPCT_ENABLE_IRQ()函数的输入。在我发布的示例中,WKUPCT_ENABLE_IRQ()函数使得中断GPIO和两个按钮的极性。在您的情况下,您应该修改wkupct_enable_irq()作为:
wkupct_enable_irq(wkupct_pin_plect(gpio_button_port,gpio_button_pin)| wkupct_pin_select(gpio_sensor_port,gpio_sensor_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_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)当我在前一篇文章中已经提到了,当设备处于扩展睡眠模式时,您只能从BLE事件唤醒,当连接时,您将根据您与您安排的预定义连接间隔唤醒和睡眠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-semicondiondiondum/forums/post/dialog-smartbond-bl ...
谢谢pm_dialog.