6.6.1 RFD Project Creation

  1. Create a new MCC Harmony Project. For more details, refer to Creating a New MCC Harmony Project from Related Links.
  2. The MAC component is available on Device Resources>Libraries>Harmony>Wireless>Drivers>IEEE 802.15.4. Add by using ‘+’ symbol. The component will be displayed on project resources section.
    Figure 6-100. Device Resources
  3. Click “Yes” for all Pop-ups to add all the dependent modules, device type selection choose as RFD and, if security required choose MAC Security Config as Enabled
    Figure 6-101. MAC Configuration
  4. Right Click on TIME module for selecting the timer source, Select TC0
    Figure 6-102. Time Component
  5. Click on Time Component>Go to Configuration Options>Change the Number of Clients as 10
    Figure 6-103. TIME Configuration
  6. The component is available on Device Resources>Libraries>Harmony>Board Support Packages>WBZ451 Curiosity BSP . Add by using ‘+’ symbol. The component will be displayed on Project resources section.
    Figure 6-104. Board Support Packages
  7. The Bluetooth LE Provisioning component is available in Device Resources>Libraries>Harmony>System Services>BLE Provisioning. Add the component by using ‘+’ symbol.
    Figure 6-105. BLE Provisioning
  8. Click “Yes” for all Pop-ups to add all the dependent modules.
    Note: The Bluetooth LE stack is configured to disable the RTC by default. To prevent the RTC from being disabled, we are activating the Deep Sleep feature subsequent to the integration of the BLE provisioning component.
    Figure 6-106. Auto-deactivation Request
  9. Select BLE Stack and change the Device Name and Local Name as MicrochipRFD.
    Figure 6-107. BLE Stack Configuration
  10. For Free-RTOS component, enable the Use Timers option and do the following modifications
    1. Set the Timer task priority as 1
    2. Set the Timer queue length as 10
    3. Set the Timer task stack depth as 256
    4. Disable Use Application Daemon Task Startup Hook
    Figure 6-108. Free-RTOS Component Configuration
  11. Add the CONSOLE component to project graph available from Device Resources>System Services>CONSOLE.
    Figure 6-109. CONSOLE Component
    1. Select the CONSOLE component from the project graph and add SERCOM0 as illustrated in the following figure.
      Figure 6-110. CONSOLE Component
    2. Configure the SERCOM0 component as illustrated in the following figure.
      Figure 6-111. SERCOM0 Component
    3. Select System and Set the SERCOM0 Direct Pin Enable as DIRECT as illustrated in the following figure.
      Figure 6-112. System
  12. For Clock configuration, go to Plugins>double click on Clock Configuration
    Figure 6-113. Clock Configuration
  13. Configure the clocks as illustrated in the following figure.
    Figure 6-114. Clock Configuration
    Figure 6-115. Clock Configuration
  14. Ensure that the project graph resembles the one illustrated in the following figure.
    Figure 6-116. Project Graph

Generating a Code

For more details on code generation, refer to MPLAB Code Configurator (MCC) Code Generation from Related Links.

Adding Files To The Project

  1. After the successful generation of the project , add the following files and folders. Copy the following folder into the project location from the Project Repository (<Harmony Content Path>\wireless_apps_pic32_bz6\apps\multiprotocol\ble_mac_prov_rfd\firmware\src).
    Figure 6-117. Adding Files To The Project
  2. Add the source and header files to the project as illustrated below
    Figure 6-118. Adding Files To The Project
    1. Add the source file to the project as illustrated below
      Figure 6-119. Adding Files To The Project
    2. Similarly add the header files to the project as illustrated below
      Figure 6-120. Adding Files To The Project
      Figure 6-121. Adding Files To The Project
  3. To add this folder to include directory, select the Project folder>ble_mac_prov_rfd>Set Configuration>Customize
    Figure 6-122. Adding File to Include Directory
  4. Select xc32-gcc>preprocessing and messages>Include directories>Browse>firmware>sensors>Open
    Figure 6-123. Adding File to Include Directory
  5. Copy the following files “app_adv.c and app_adv.h” into the project location from the Project Repository (<Harmony Content Path>\wireless_apps_pic32_bz6\apps\multiprotocol\ble_mac_prov_rfd\firmware\src). These files enable the Bluetooth LE advertisement service.
    Figure 6-124. Adding Files To The Project
    1. Follow step 2 above to add the source and header files, respectively.

Code Modifications For RFD project

  • Code changes in app_ble_handler.c file
    Figure 6-125. app_ble_handler.c
  • Code changes in app_trps_handler.c file
    Figure 6-126. app_trps_handler.c
    Figure 6-127. app_trps_handler.c
  • Code changes in app_ble_conn_handler.c file
    Figure 6-128. app_ble_conn_handler.c
    Figure 6-129. app_ble_conn_handler.c
    Figure 6-130. app_ble_conn_handler.c
  • Code changes in app.c file
    Figure 6-131. app.c
    Figure 6-132. app.c
    Figure 6-133. app.c
    Figure 6-134. app.c
  • Code changes in app.h file.
    Figure 6-135. app.h
    Figure 6-136. app.h
  • Code changes in app_idle_task.c file
    Figure 6-137. app_idle_task.c
    Figure 6-138. app_idle_task.c
    Figure 6-139. app_idle_task.c
  • Code changes in freertos_hooks.c file
    Figure 6-140. freertos_hooks.c
    Figure 6-141. freertos_hooks.c
  • Code changes in initialization.c file
    Figure 6-142. initialization.c