4.1.1.1 Central - FreeRTOS BLE Stack and App Initialization
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.
Recommended Reading
Hardware Requirement
-
None
Software Setup
Initiating a BLE Stack
Create a new MCC Harmony Project. For more details, refer to Creating a New MCC Harmony Project
- Open the MPLAB Code Configurator:Default MPLAB Code Configurator window
- 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.
- 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.
- The project graph will resemble the following image.
- 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.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"
- Click on the BLE Stack component in
project graph, open Configuration Options and
- Peripheral Device functionality is enabled by default, this must be unchecked (BLE Stack>Generic Access Profile (GAP)>Peripheral)
- Central configuration must be checked (BLE Stack>Generic Access Profile (GAP)>Central)
Figure 4-9. BLE Stack Generate the code. For more details on code generation, refer to the Generate Code section
-
Before building the code, user action is required. For more details, refer to the User Action section.
- Switch to MPLAB X IDE window and Build Project. The project must compile successfully.
Choose the correct compiler version, as suggested in development environment section.
For more information, refer to UART