亲爱的Dialog_Support,
我们正在开发应用程序,我们将使用两个中断方法唤醒设备。
1. Using push button interrupt
2传感器中断[如果传感器中断引脚上有任何活动]
I have referred the ble_sleep_mode example but for my application it not working properly.
我用下面的代码片段来配置中断,
静态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\设置\睡眠\模式(应用\默认\睡眠\模式);
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(应用程序按钮按下_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), // polarity low
1,//1事件
40); // debouncing time = 0
}
void user_app_adv_undirect_complete(uint8_t status)
{
// Disable wakeup for BLE and timer events. Only external (GPIO) wakeup events can wakeup processor.
如果(状态==间隙\u错误\u取消)
{
用户_app_adv_start();
//配置唤醒按钮
应用程序按钮启用();
}
}
Using this i am unable to generate interrupt and wake my device from sleep.
一些随机行为正在发生,就像只有第一次我能够检测到按钮中断,如果重复第二次未能检测到。
与传感器中断相同。
Please help me solve issue.
谢谢并恭祝安康
Rohit
Hi Rajapurerohit,
Could you please clarify what you want to do with your application? 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?
醒来可能失败的几个原因:
• In user_app_adv_undirect_complete() function you don’t call arch_ble_ext_wakeup_on() function, as the ble_app_sleepmode example of the SDK. This function turns the sleep_ext_force variable to true when the advertising is completed, which is by default false. When the app_button_press_cb() function is triggered by pressing the button, the arch_ble_ext_wakeup_get() returns the default value which is false, so the code into if (arch_ble_ext_wakeup_get()) will not execute. So, I suggest to check that.
•此外,您还应检查唤醒引脚的状态,并确保它们都是高电平(因为您已将唤醒配置为在低电平时触发)。因为如果两个源中的一个保持中断状态(在您的情况下为低),那么当另一个中断切换到低时,唤醒控制器将不会被触发。
•此外,您是否再次在应用程序代码中启用按钮?如果启用一次,只有第一次您才能检测到按钮中断。那么,在您想从外部中断中唤醒之前,您是否调用了app_button_enable()?
Thanks PM_Dialog
你好pm_dialog,
谢谢你的回复。
My requirement is,
1.将设备配置为扩展睡眠模式,当按钮中断、传感器中断以及连接后是否写入特征时唤醒。
2在做广告和连接的时候可以睡觉吗?
其次,希望在广告期间在睡眠中设置设备,但它应该在我的移动应用程序上显示,即使它在睡眠状态。
如果移动应用程序连接,则睡眠。可能吗?如果是,我应该遵循哪种算法。
3.现在实现的算法是每当有按钮或传感器中断时唤醒设备,但当有按钮中断时无法唤醒设备,我在前面的评论中附上了代码片段。
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_端口,SENSOR_INT,GPIO2_IRQn,假,真,250);
GPIO_RegisterCallback(GPIO2_IRQn, SENSORInterruptHandler);
谢谢并恭祝安康
Rohit
Hi Rajapurerohit,
1、2)广告之间的设备进入睡眠and connection intervals. The device can wake up either from a pre programmed BLE event (an advertising event or a connection event or a kernel timer) or with a wake up interrupt. For example in the advertising case the device will wake up advertise and the will go back to sleep again and it will not advertise until the time elapses for the next advertising interval. I am not able to get what you mean that your device should display on your mobile phone even though it is in sleep. Could you please clarify your question?
3)在您在上一篇文章中发布的配置中,您已在GPIO上配置了中断。此中断将仅在您的设备唤醒时执行,并且它是广告。此配置无法在睡眠期间唤醒设备,当设备进入睡眠模式时,应使用唤醒控制器,以便外部中断唤醒它。
谢谢pm_dialog.
你必须了解设备是如何工作的,设备将根据广告时间间隔唤醒并进行广告宣传,因此,您可以将设备置于永久睡眠状态,仅通过按钮或内核计时器唤醒,或者您可以设置标准的广告时间间隔,以便设备自动唤醒(后者是唯一可以从中央发现的方法)。我还提到了一些您在附加的代码实现中没有遵循的事项:
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. Also after the timer app_adv_data_update_timer_used is called you invoke the stop advertising and then you restart the advertising and then you enable the wake up interrupt, and also you are enabling it wrong (passing wrong parameters) since the you have mixed up the pin parameter with the polarity parameter (please check the parameters that the function accepts or check this forum tickethttps://support.dialog-semicondiondiondum/forums/post/dialog-smartbond-bl ...). 另外,当来自外部源的中断发生时,您可以在仍在播发的同时发送一个启动播发命令,但由于您从未启用过arch_ble_ext_wakeup_get(),它将始终返回flash,因为您从未启用过arch\uext_wakeup_on()(这是我曾经做过的)在上一篇文章中已经提到)。
To conclude, i am not able to figure out what exactly the code that you have attached should do, or what you would like to do, i would suggest to have a look at the ble_app_sleepmode examples and try to understand how exactly the system operates.
谢谢pm_dialog.
嗨,PM\U对话,
谢谢你的回复。
但我无法理解wkupct_enable_irq();它是如何工作和什么极性。
In data sheet also there no much explanation. Can you please give me example of two interrupt pins configuration.
从附加的链接,我也不能清除我的引脚中断。
If follow the sleep mode example configuration , i am not able detect both interrupt or it work only with one interrupt second one wont work.
请帮我解决问题。
谢谢并恭祝安康
Rohit
Hi 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.
#定义GPIO_按钮_2_PIN GPIO_PIN_6
2) Reserve the button2. Got to the user_periph_setup.c file and add in GPIO_reservations() function the following code:
RESERVE_GPIO(PUSH_BUTTON, GPIO_BUTTON_2_PORT, GPIO_BUTTON_2_PIN, PID_GPIO);
3) 转到user\u periph\u setup.c并在set\u pad\u functions()函数中添加以下代码:
GPIO_配置PIN(GPIO_按钮_2_端口,GPIO_按钮_2_引脚,输入_PULLUP,PID_GPIO,false);
4) In the sleep_mode.c, replace app_button_enable() function with the below function. The following function sets up both buttons as wake up interrupt.
静态无效应用按钮启用(无效)
{
app_easy_wakeup_set(app_wakeup_cb);
wkupct_register_callback(应用程序按钮按下_cb);
wkupct_enable_irq(WKUPCT_PIN_SELECT(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN) | WKUPCT_PIN_SELECT(GPIO_BUTTON_2_PORT, GPIO_BUTTON_2_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_button_2_port,gpio_button_2_pin,wkupct_pin_polarity_low),//极性低
1,//1事件
40); // debouncing time = 0
}
If you follow the below steps, you must be able to have two interrupt pins configuration and wake up your device using either of them. Also, I suggest you to check again the three possible reasons that the waking up in your application might fail.
谢谢pm_dialog.
你好,下午好对话,
谢谢你的回复,
i have changed function and it works well for me.
basically my end goal is to reach following part
1.Be awake after switch was pressed and go back to sleep after 6 seconds if button is not pressed
(检测到的运动)再次
2.在检测到运动后醒来,6秒后恢复睡眠,如果动作不是
再次检测到(按下开关)
3. Be awake after you received something in connected state and need to buzz. Then go back
6秒后睡觉,如果没有检测到动作(切换)再次
我用定时器0和定时器2来产生pwm。但在写上述流量时,m不能正确连接设备,pwm也不能正常工作,因为它总是进入休眠状态。
你能帮我用定时器在6秒后起床睡觉吗
谢谢并恭祝安康
Rohit
Hi 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_极性(GPIO_BUTTON_PORT,GPIO_BUTTON_PIN,WKUPCT_PIN极性低)| WKUPCT_PIN极性(GPIO_SENSOR_PORT,GPIO_SENSOR_PIN,WKUPCT_PIN极性低),//极性低
1,//1事件
40); // debouncing time = 0
例如,GPIO\传感器\端口和GPIO\传感器\引脚。在你的应用程序中,你应该把你的GPIO传感器定义作为输入。为了在您醒来时播发6秒,您应该更改播发数据时间的值。请转到user_sleepmode.h文件并将APP_ADV_DATA_UPDATE_的值更改为600。另外,我建议您检查传感器的极性,以便捕捉中断并触发唤醒控制器。例如,如果传感器的极性低,并且您将唤醒控制器的极性配置为低,则中断不会被捕获,唤醒控制器也不会被触发。我在前一篇文章中提供的例子设置了两个来源的唤醒信号,你可以使用它,用你的传感器的极性用中断代替按钮。
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.