Broadcasting via GPIO interruption

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at https://www.dialog-semiconductor.com/support . We’ll be fixing bugs / optimising the searching and tagging over the coming days.
5 posts / 0 new
Last post
Nick Long
Offline
Last seen: 1 year 8 months ago
Joined: 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: 1 year 8 months ago
Joined: 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: 7 months 1 week ago
Staff
Joined: 2018-02-08 11:03
Hi Nick Long,

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.

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

Thanks, PM_Dialog

Nick Long
Offline
Last seen: 1 year 8 months ago
Joined: 2020-05-20 04:00
Hi PM_Dialog. Thanks for your

Hi PM_Dialog. Thanks for your reply. You are right. I can modify the ble_app_sleepmode example to realize my purpose. And I found a post https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bl... to give the procedure. Following are the steps your Dialog stuff gave:

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) 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)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)change mnf_data_update() like this for counting.
static 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!

Regards,
Nick

PM_Dialog
Offline
Last seen: 7 months 1 week ago
Staff
Joined: 2018-02-08 11:03
Hi Nick Long,

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