10. Building a DA1469x Application – Advertising Demo

10.1. Introduction

The following sections explain how the user can build, program and run a simple software application called Advertising Demo ble_adv on the ProDK development board using the SmartSnippets™ DA1469x SDK.

The application is first described, then step by step instructions are given to build and run it.

10.2. Software Architecture

In order to get familiar with building and executing ble_adv project, it is better to run it in debug mode first. This is the easiest setup and does not need any Flash programming prior to executing the binary.

When the application starts running the first thing that is executed is the Reset_Handler, which is located in startup > startup_ARMCM0.s. This is followed by setting IRQ priorities and initializing variables.

Next, code execution continues with the main subroutine in file main.c. Here, the main routine creates the task SysInit and starts the RTOS scheduler. From now on the RTOS scheduler is running and it will start the first task which is SysInit.

The SysInit first initializes the clock and the low power clock and sets the clock dividers for AHB and APB buses. Then BLE Adv is initialized which leads to function initialization of BLE manager.

Last thing done before SysInit task exits is to create another task ble_adv_demo_task which is the main application task running until the program gets stopped. The function code implementing this main task is as follows:

Code 2 The main task in SysInit() the ble_adv_demo_task()
static void ble_adv_demo_task(void *pvParameters)
        int8_t wdog_id;

        /* Just remove compiler warnings about the unused parameter */
        ( void ) pvParameters;

        /* Register ble_adv_demo_task to be monitored by watchdog */
        wdog_id = sys_watchdog_register(false);

        /* Start BLE device as a peripheral */

        /* Set device name */
        ble_gap_device_name_set("Dialog ADV Demo", ATT_PERM_READ);

        /* Set advertising data */
        ble_gap_adv_data_set(sizeof(adv_data), adv_data, 0, NULL);

        /* Start advertising */

        for (;;) {
                ble_evt_hdr_t *hdr;

                /* Notify watchdog on each loop */

                /* Suspend watchdog while blocking on ble_get_event() */

                 * Wait for a BLE event - this task will block
                 * indefinitely until something is received.
                hdr = ble_get_event(true);

                /* Resume watchdog */

                if (!hdr) {

                switch (hdr->evt_code) {
                case BLE_EVT_GAP_CONNECTED:
                        handle_evt_gap_connected((ble_evt_gap_connected_t *) hdr);
                case BLE_EVT_GAP_DISCONNECTED:
                        handle_evt_gap_disconnected((ble_evt_gap_disconnected_t *) hdr);
                case BLE_EVT_GAP_PAIR_REQ:
                        handle_evt_gap_pair_req((ble_evt_gap_pair_req_t *) hdr);

                /* Free event buffer (it's not needed anymore) */

10.3. Software Build

This section describes all the steps required to import, build and run this first project.

  1. In the SmartSnippets™ Studio welcome page click on the IDE icon from the Tools tab as shown in Figure 47.


Figure 47 SmartSnippets™ Studio welcome page

  1. Import the template project ble_adv from: <sdk_root_directory>/projects/dk_apps/demos/ble_adv into the selected workspace. Press the browse button highlighted in the Resources tab (reference 1) and navigate to the folder which contains the specific project as shown in Figure 48.


Figure 48 Project import

  1. In the same way import the python_scripts project from:


10.3.1. Build the project to run from RAM

The first build to try is a RAM build. This is the simplest one as there is no need to write the code to external QSPI Flash, the debugger will load it directly into RAM from where it can be run. This is not the normal method of development.

Build the project with the Build button and select Debug RAM configuration DA1469x-00-Debug-RAM as shown in Figure 49.


Figure 49 Build ADV BLE in Debug RAM configuration

Once the Debug RAM binary is built, the next step is to start the Debugger using as shown in Figure 50. As this is a RAM build the debugger will download the binary file via J-Link debugger into the system RAM. To enable this the system RAM is mapped to address 0 by the debugger.


Figure 50 Start Debug in RAM mode

10.3.2. Build the project to run from QSPI Flash

  1. This will be the normal development flow which has three steps: build the code, write it to QSPI Flash and then run it in the debugger. Some questions may pop-up about which Flash device etc, as explained later in the next section: Configure |SmartSnippets (TM)| to write to Flash

  2. Build the project pressing the build button and select the Debug QSPI configuration DA1469x-00-Debug-QSPI as shown in Figure 51.


Figure 51 Build ADV BLE in Debug QSPI configuration

The next step is to write the binary file to QSPI Flash. This is done by using a script selected from the External Tool button. In Figure 52 select program_qspi_jtag to program the QSPI Flash memory. (The external tools may not be populated at first use. To populate the External Tool button, press the External Tools Configuration… button to manually add the menu items.)

Alternatively, use Run > External Tools > program_qspi_jtag.


Figure 52 Write ADV BLE to QSPI Flash

Finally start the debugger as shown in Figure 53. This will start the debug perspective in SmartSnippets™ and load the symbols for the current project into the debugger.


Figure 53 Start Debug in QSPI mode

10.4. Configure SmartSnippets™ to write to Flash

In order to write an Your_First_DA1469x_Application-Advertising_Demoo another Flash version a configuration must be done first. To access configuration menu alternatively, use Run > External Tools > program_qspi_config program_qspi_config, refer to Figure 52. This will open the window as shown in Figure 54 with a summary of the current QSPI configuration and supported device.


Figure 54 Configuration Summary

Press change to apply a new configuration. The first question has to do with the Product Id Select DA1469x-00 product family.


Figure 55 Select Product ID

Next you will asked about the Flash configuration. For ProDK of the DA1469x family select MX25U3235F.


Figure 56 Select Flash configuration

Finally you will be asked to insert an address about Active FW Your_First_DA1469x_Application-Advertising_Demoddress and Update FW Your_First_DA1469x_Application-Advertising_Demoddress. Please keep in both entries the default value 0x2000.


Once your project is loaded and it is not working, it could that a wrong flash version was chosen. make sure to select the right flash version refer to Figure 56.

10.5. Running the project in the Debugger

  1. Now that the binary has been loaded to memory (either RAM by debugger or QSPI by script) and the debugger has the symbols for the project loaded it is possible to run project in the debugger.

  2. Start execution of the ADV BLE project by selecting Resume inside the SmartSnippets™ Run menu or by hitting the play icon as indicated in Figure 57.


Figure 57 Executing the ADV BLE project in SmartSnippets™

  1. The correct functionality of the ADV BLE project can be checked by noticing in the BLE scanner application.


Figure 58 ADV BLE: Interacting with BLE Application

10.6. How to Program the original FW back into the QSPI Flash

In this section we will describes how you can Program the original FW back into the QSPI Flash In This Small SW example : DA1469x_dev_kit_demo , You can built and write to the QSPI flash as it shown in: Build the project to run from QSPI Flash or you can compile it and write the built .bin to the Flash using <sdk_root_directory>/binaries/cli_programmer.exe as shown in Figure 59.

Code 3 Command to Write binary to the QSPI Flash using cli_programmer
./cli_programmer.exe gdbserver write_qspi 0x0 pro_kit_demo.bin

Figure 59 Write binary to the QSPI Flash using cli_programmer

10.7. What Next ?

This tutorial does not cover all the topics relevant to the software development environment. It describes the first steps necessary to get started with the Pro Development Kit. For further reading the following links provide more information on DA1469x: