4.1.1.1 Central - FreeRTOS BLE Stack and App Initialization

Getting Started

Getting Started with Central Building Blocks

Introduction

This section gives a detail information on creating a new MCC Harmony project, configuring FreeRTOS component and BLE stack component in the project and generating code using the MPLAB MCC framework.

Recommendation is to follow the examples in order, by learning the basic concepts first and then progressing to the more advanced topics.

Hardware Requirement

  • None

Software Setup

Initiating a BLE Stack

This section explains the steps required to develop this application example from scratch using MPLAB® Code Configurator.
Note: It is recommended that new users of MPLAB Code Configurator go through the overview
  1. Create a new MCC Harmony Project. For more details, refer to Creating a New MCC Harmony Project

  2. Open the MPLAB Code Configurator:
    Figure 4-1. MCC
    Default MPLAB Code Configurator window
    Figure 4-2. Default MCC Window
  3. To add the BLE Stack component to the project graph, go to Harmony>Wireless>Drivers>BLE>BLE Stack from the “Device Resources” field as illustrated in the following figure.
    Figure 4-3. BLE Stack
    Figure 4-4. Project Graph
  4. Upon selection, user will receive a prompt for auto-activation and auto-connect request of different component dependencies. Select Yes to add all the dependent components and also for all attachment auto-connect requests.
    Figure 4-5. Auto-Activation
    Figure 4-6. Auto-Activation and Auto-Connect
  5. The project graph will resemble the following image.
    Figure 4-7. Project Graph
  6. Click on the FreeRTOS component in project graph, open Configuration Options and configure as illustrated in the following image. the configuration must suit most application needs, users are recommended to follow the FreeRTOS customization documented in FreeRTOS website to meet their needs.
    Figure 4-8. FreeRTOS
    Note: Upon selecting any component, the default configuration options available for user are displayed.
    Note: By default, the "Total heap size" is set to a default value which might not be sufficient to a specific project. If the total heap size is not enough, vApplicationMallocFailedHook( ) will be caught. Then user can adjust the "Total heap size" to avoid this situation.
    Note: It is required to address the heap needed or BLE stack library as defined in initialization.c #define EXT_COMMON_MEMORY_SIZE (22*1024). Hence the default "Total heap size"
  7. Click on the BLE Stack component in project graph, open Configuration Options and
    1. Peripheral Device functionality is enabled by default, this must be unchecked (BLE Stack>Generic Access Profile (GAP)>Peripheral)
    2. Central configuration must be checked (BLE Stack>Generic Access Profile (GAP)>Central)
    Figure 4-9. BLE Stack
  8. Generate the code. For more details on code generation, refer to the Generate Code section

  9. Before building the code, user action is required. For more details, refer to the User Action section.

  10. Switch to MPLAB X IDE window and Build Project. The project must compile successfully.
  11. Choose the correct compiler version, as suggested in development environment section.

For more information, refer to UART