5.1.2.1 Peripheral - FreeRTOS BLE Stack and App Initialize
This section explains how to create a new MCC Harmony project, configure the FreeRTOS and BLE stack components in the project and generate code using the MPLAB Code Configurator (MCC).
It is recommended to follow the examples in sequence to understand the basic concepts before progressing to the advanced topics.
Recommended Readings
-
Getting Started with Application Building Blocks – See Building Block Examples from Related Links.
-
Getting Started with Peripheral Building Blocks – See Peripheral Devices from Related Links.
-
FreeRTOS and BLE Stack Setup – See Peripheral - FreeRTOS BLE Stack and App Initialize from Related Links.
-
BLE Software Specification – See MPLAB® Harmony Wireless BLE in Reference Documentation from Related Links.
Hardware Requirement
None
Software Setup
Refer to Getting Started with Software Development from Related Links.
Steps to Init BLE Stack
- Create a new harmony project. For more details, see Creating a New MCC Harmony Project from Related Links.
- Open the MPLAB Code Configurator.
Figure 5-82. MPLAB Code Configurator Default MPLAB Code Configurator window shown as follows.Figure 5-83. Default MCC Window - In the Device Resources window,
expand Libraries>Harmony>Wireless>Drivers>BLE and click the
plus symbol next to the BLE Stack component to add it on to the
project graph.
Figure 5-84. BLE Stack - After BLE Stack is added to the
project graph, different component dependencies will be requested to be added as
well. User has to select yes to add the dependent components.
Figure 5-85. Auto-Activation and Auto-Connect Request - Verify the Project Graph.
Figure 5-86. Project Graph - Display the FreeRTOS component configuration options by selecting the component
in the project graph. Configure the FreeRTOS component to the following.
The configuration chosen here must suit most application needs. It is
recommended to refer the FreeRTOS Customization in Reference
Documentation from Related Links. Note: Upon selecting any component, the default configuration options available for the 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 caght. 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" allocated by core component is not sufficient. Allocate atleast
59392size - Display the BLE Stack component configuration options by selecting the component in the project graph. Configure the BLE Stack component to the following. By default, the peripheral device functionality is enabled.
- To generate the code, refer to MPLAB Code Configurator (MCC) Code Generation from Related Links.
- Switch to the IDE window, right click on the project, and open the Project Properties.
- Ensure correct compiler version as suggested in Getting Started with Software Development is chosen then click apply. For more details, refer to Getting Started with Software Development from Related Links.
- Build Project and upon building the project, user action is required. For more information, refer to User Action from Related Links.
- Build Project again and the project will now compile successfully.
