Skip to main content

Broadcasting via GPIO interruption

3 months ago

Broadcasting via GPIO interruption

Posted byNick Long0 points 4 replies
0 upvotes

您好对话框的东西,我计划根据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.

你能告诉我一个有关实现的详细程序吗?这将是非常感激的。

3 months ago

Nick Long 0 points

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.

3 months ago

PM_Dialog

Hi Nick Long,

Thanks for your 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.

本例还演示了如何更新制造商特定数据。请参阅mnf_data_update()函数。

Thanks, PM_Dialog

3 months ago

Nick Long 0 points

嗨pm_dialog。感谢您的回复。你是对的。我可以修改BLE_APP_SLEEPMODE示例以实现我的目的。我找到了一篇文章https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-b…给出程序。以下是您对话框的步骤给出了以下步骤:

1)注释出在user_app_adv_start()函数中调用的app_easy_timer()。此计时器摘要通过app_easy_gap_advertise_stop()函数停止广告每个app_add_data_update_to秒的adv_data_update_timer_cb()函数。
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) Add the app_button_enable into the user_app_adv_start() in order to upadate the advertising data by pressing the button
4) Then in the user_app_adv_undirect_complete() comment out the arch_ble_ext_wakeup_on() and the app_button_enable() and add user_app_adv_start(). The user_app_adv_start() will start the advertising after the update of the advertising data.

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.

But there is still something he did not illustrate clearly. Below are my realization steps based on my understanding. could you please check whether they are correct?

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)根据我的需要,更改GPIO_BUTTON_PORT,GPIO_BUTTON_POLARY_LOW在APP_BUTTON_ENABLE()函数的定义中。

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)change mnf_data_update() like this for counting.
static void mnf_data_update()
{
mnf_data.proprietary_data [1] ++;
}

在通过这五个步骤修改代码之后,当我将我设置为按钮的P0_1将其设置为按钮,到GND,我的扫描仪应用程序中显示的制造商数据将添加一个。但是,这不起作用非常稳定。有时DA14531将停止宣传,我无法通过将P0_1连接到GND来唤醒它。我只能按RESET按钮以获得新计数。你能帮这个问题吗?非常感谢!

问候,
Nick

3 months ago

PM_Dialog

Hi Nick Long,

Thanks for your response. I would recommend you start debugging the project.So, please run it in debug mode and check if the firmware is rerunning correctly. Is the fw running, or it freezes into an assertion, NME etc. ? Add also some breakpoints, so you can verify that all is working as expected.

Question : Does the device boot from SPI Flash or System-RAM? In case of System-RAM, what is the behavior?

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