Broadcasting via GPIO interruption

Learn MoreFAQsTutorials

5个帖子/ 0新
Last post
Nick Long
Offline
Last seen:2 days 15 hours ago
加入:2020-05-20 04:00
Broadcasting via GPIO interruption

Hello Dialog stuff, I am planning to develop a counter based on DA14531.
The final effect is that when the P0_1 pin of DA14531 detects a rising edge, a variable say COUNTER will add 1, and then the value of COUNTER will be advertised three times subsequently. After that DA14531 goes to sleep and listens for the next interruption on PIN P0_1. I will see the value of the COUNTER in the manufacturer specific data on the smartphone scanner APP .
I think combining the Timer1_Software_Example and ble_app_barebone example may realize my goal. However, I tried and failed.

Could you please give me a detailed procedure to achieve that. That would be very appreciated.

Device:
Nick Long
Offline
Last seen:2 days 15 hours ago
加入:2020-05-20 04:00
Hi,

Hi,

I have found another example to achieve my purpose. That is the Ble_Button_Wakeup example. However, I add a global variable COUNTER in the user_wakeup.c and the code "COUNTER++;" in the user_app_wakeup_press_cb () function. How can I update the value of COUNTER into the "mnf_data.proprietary_data[1]" in the user_barebone.c and advertise this value? Could you please help with that? THANKS.

PM_Dialog
Offline
Last seen:2 hours 25 min ago
Staff
加入:2018-02-08 11:03
Hi Nick Long,

Hi Nick Long,

谢谢你的question online. I think that best project to get started is the ble_app_sleepmode example of the SDK6.

You can found it in 6.0.14.1114\projects\target_apps\ble_examples\ble_app_sleepmode SDK path.

This example is using the Wake-up controller to wake up the device. Please check the app_button_enable(). In order to detect a high level signal, the polarity should be changed from WKUPCT_PIN_POLARITY_LOW to WKUPCT_PIN_POLARITY_HIGH.

This examples also demonstrates how to update the manufacturer specific data. See mnf_data_update() function.

Thanks, PM_Dialog

Nick Long
Offline
Last seen:2 days 15 hours ago
加入:2020-05-20 04:00
嗨pm_dialog。谢谢你的

嗨pm_dialog。谢谢你的reply. You are right. I can modify the ble_app_sleepmode example to realize my purpose. And I found a posthttps://support.dialog-semicondiondiondum/forums/post/dialog-smartbond-bl ...给出程序。以下是您对话框的步骤给出了以下步骤:

1) Comment out the app_easy_timer() that is invoked into the user_app_adv_start() function. This timer excecutes the adv_data_update_timer_cb() function that stop advertising every APP_ADV_DATA_UPDATE_TO seconds by app_easy_gap_advertise_stop() function.
2) Regarding the update of the advertising string you should stop adverting, then update dynamically your data and then start again advertising. In the app_wakeup_cb() function add the app_easy_gap_advertise_stop() to stop advertising.
3)添加app_button_enable into the user_app_adv_start() in order to upadate the advertising data by pressing the button
4)然后在user_app_add_undirect_complete()中注释出ARCH_BLE_EXT_WAKEUP_ON()和APP_BUTTON_ENABLE()并添加USER_APP_ADV_START()。user_app_adv_start()将在更新广告数据后启动广告。

The app_button_enable() function sets up the button as wakeup trigger event and sets up the wakeup controller. The wkupct_register_callback() registers the app_button_press_cb() function which is going to be invoked in the wakeup controller. Also, wkupct_enable_irq() selects the GPIO in which the button is connected and will triggered when the wake up interrupt will be happened.

但仍然有一些他没有清楚地说明的东西。以下是我的理解实现步骤。请你检查它们是否正确?

1)comment out app_adv_data_update_timer_used = app_easy_timer(APP_ADV_DATA_UPDATE_TO, adv_data_update_timer_cb); in the user_app_adv_start() function, and add app_button_enable() function in the first line in the user_app_adv_start() function. I am not sure whether the position of app_button_enable() function is right.

2)add app_easy_gap_advertise_stop() and mnf_data_update() functions in the last two lines in the app_button_press_cb() function.

3)change the GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW according to my need in the definition of app_button_enable() function.

4)comment out arch_ble_ext_wakeup_on() and app_button_enable() functions in the user_app_adv_undirect_complete() function, and add user_app_adv_start() function subsequently.

5)更改像这样的mnf_data_update()以计数。
静态void mnf_data_update()
{
mnf_data.proprietary_data[1]++;
}

After modifying the codes through these five steps, when I connect the P0_1, which I set as the button press pin, to GND, the manufacturer data shown in my scanner APP will add one. However, this does not work very stable. Sometimes the DA14531 will stop advertise and I cannot wake up it by connecting P0_1 to GND. And I can only press the reset button for a new counting. Could you please help with this problem? Thanks a lot!

问候,
Nick

PM_Dialog
Offline
Last seen:2 hours 25 min ago
Staff
加入:2018-02-08 11:03
Hi Nick Long,

Hi Nick Long,

感谢您的答复。我建议您开始调试Project.so,请在调试模式下运行它,并检查固件是否正确速度。是fw运行,还是它冻结到一个断言,nme等?添加一些断点,因此您可以验证所有是否正常工作。

问题:设备是否从SPI Flash或System-RAM启动?在系统RAM的情况下,行为是什么?

You can run it in debug mode by pressing the “Start/Stop Debug session” button and then the “Run” button from the Keil IDE?

Thanks, PM_Dialog