7.4 Creating a New P2P PHY MCC Harmony Project

  1. To create a new project, perform the following steps:
    1. Open MPLAB X IDE.
    2. Navigate to File>New Project.
    Figure 7-1. New Project
  2. In the New Project window, click on Microchip Embedded>Application Project(s)>Next.
    Figure 7-2. Choose Project
  3. In Select Device tab, perform the following steps:
    1. From the “device:” drop-down list, select WBZ351.
    2. Click Next to continue.
    Figure 7-3. MCC Project Creation
  4. In the Select Compiler tab, perform the following steps:
    1. Under “XC32 [Download Latest]”, select the latest compiler.
    2. Click Next to continue.
    Figure 7-4. Select Compiler
  5. In the Select Project Name and Folder tab, perform the following steps:
    1. In the “Project Name:” field, enter the project name.
    2. In the “Project Location” field, enter the project location.
    3. In the “Project Folder:” field, browse and select the project folder.
    4. Click Finish to continue.
    Figure 7-5. Select Project Name and Folder
  6. Now MPLAB X Code Configurator Content Manager automatically launches. It sets up the configuration and initiates the project.
    Figure 7-6. MCC Required Content
    1. After a while, the MCC displays the project graph containing the default components:
      • CMSIS Pack
      • System
      • Device Family Pack (DFP)
      • EVSYS
      Figure 7-7. Project Graph
    2. The following figure illustrates the Project Resources tab and the Device Resources tab.
      Figure 7-8. Project and Device Resources Tab
  7. In the Device Resources tab, perform the following steps:
    1. Navigate to Libraries>Harmony>Wireless>System Services.
    2. Locate “IEEE 802.15.4 PHY APP” component.
    3. Expand “IEEE 802.15.4 PHY APP” component, click the plus symbol (green) next to IEEE 802.15.4 PHY APP to add the component to project graph.
      Figure 7-9. Adding IEEE 802.15.4 PHY APP Component
    4. After adding the component, the MCC automatically prompts the user to accept any required dependencies or satisfiers.
    5. Click Yes to accept all dependencies. The MCC adds all necessary modules and connections for the IEEE 802.15.4 PHY components to function correctly.
      Figure 7-10. Components Auto-Activation Confirmation
    6. The following figure illustrates the MCC project graph and helps the user verify the addition of all necessary components and properly connect them.
      Figure 7-11. Project Graph – Adding P2P PHY APP Component
  8. After the auto-population of all the components, the user needs to manually select the following dependencies.
    1. The user must manually connect the CONSOLE component to its consumer SYS_COMMAND.
      Figure 7-12. Project Graph – COMMAND (sys_command) Component
    2. The user must ensure to connect the CONSOLE component to it’s dependency component SERCOM0 UART.
      Note: SERCOM 0 UART is specific to WBZ351 curiosity board, other SERCOMs can be selected as per the device selection.
      Figure 7-13. SERCOM0 Component Selection
    3. Dependencies like timer for IEEE 802.15.4 PHY component needs to be added. (explained in API guide/user guide for the PHY component).
      Figure 7-14. Timer Selection
  9. The following image illustrates the complete graph required for generating the application. Verify if the Project Graph window includes all the expected MCC configurations.
    Figure 7-15. Full Project Graph – P2P PHY APP Component
  10. The following figure illustrates the steps for configuring prior to project generation.
    1. In the Configurations Options tab, perform the following steps:
      1. Expand “DEVCFG1”.
      2. From the “SERCOM0 Direct (High Speed) Pin Enable (SCOM0_HSEN)” drop-down list, select PPS.
      Figure 7-16. System Configuration – P2P PHY APP (SCOM0_HSEN)
    2. In the Configurations Options tab, perform the following steps:
      1. Expand “RTOS Configuration”.
      2. Under “Tick Mode” drop-down list, select Tick_Interrupt.
      Figure 7-17. FreeRTOS Configuration – Tick Mode
    3. SERCOM0 PAD configuration and pin settings. The following figure illustrates the configuration of the SERCOM0.
      1. Expand “SERCOM0”.
      2. From the “Receive Pinout” drop-down list, select SERCOM PAD[1] is used for data reception.
      3. From the “Transmit Pinout” drop-down list, select PAD[0] = TxD; PAD[2] = RTS; PAD[3] = CTS.
      Figure 7-18. SERCOM0 Configuration – Receive/Transmit Pinout
    4. For pin configuration, navigate to Plugins:>Pin Configuration
      Figure 7-19. Pin Configuration
      Note:
      • Flow Control: The P2P PHY application requires the user to enable RTS and CTS flow control. To enable SERCOM0 hardware flow control on the WBZ351 Curiosity Board using RTS and CTS, configure the TxD/RxD/RTS/CTS. For more details, see step 10c, SERCOM0 Configuration – Receive/Transmit Pinout figure. At the same time, ensure to set the “SERCOM0 Direct (High Speed) Pin Enable (SCOM0_HSEN)” of DEVCFG1 as PPS. For more details, see step 10a, System Configuration – P2P PHY APP (SCOM0_HSEN) figure.
      • Hardware Modification: By default, the PB4 pin connects to the XPRO header. To use the UART_CTS pin, thee user must populate resistor (R3).
    5. The user can choose the SYS_CONSOLE BUFFER configuration according to the requirement.
      Tip: The recommendation is to have the maximum value possible.
      1. Expand “CONSOLE”.
      2. Set the “Console Print Buffer Size (128-8192)” value to 8,000.
      Figure 7-20. Console Configuration – Console Print Buffer Size
    6. To increase the stack size in “COMMAND” configuration, perform the following steps:
      1. Expand “RTOS settings”.
      2. Set the “Stack Size (in bytes)” value to 2,048.
      Figure 7-21. RTOS Settings – Stack Size
    7. P2P PHY APP component configuration options (the user can modify according to the requirement).
      Figure 7-22. P2P PHY APP Configuration
  11. Click on the Generate button available under MCC to generate the code.
    Figure 7-23. MCC Project code Generation
  12. MCC automatically generates files and routines.
    Figure 7-24. MCC Project code Generation
    • After generating the code from MCC tool by clicking Generate, below is the project folder structure.
      Figure 7-25. MCC Project Code Generation
    • The following code snippet shows modifications that the user needs to add in MCC generated files (lines to be modified are highlighted).
      • Open the tasks.c file.
      • Add the following modifications in the tasks.c file in the places highlighted in the following figures.
        TaskHandle_t xSYS_CMD_Tasks;
        Figure 7-26. Application Edits
        Figure 7-27. Application Edits
        Note: The user must manually perform the above modifications for H3 repos using Core package version 3.12.1 or below. For the next release version of the core, these changes will be automatically generated.
      • Change argument of SYS_Load_Cal() function to WSS_ENABLE_ZB in initialization.c file (This is mandatory for using the PHY library component).
        Figure 7-28. Application Edits
  13. User Application Development
    • Compile MCC auto generated project as shown in following figure.
      Figure 7-29. user edits
    • To address the mandatory error in the app_user_edits.c file, the users need to take specific actions. The error message in the output window provides a direct link to the file where the issue is located. By following the steps outlined in the app_user_edits.c, the users can make the necessary changes to resolve the error.
      Figure 7-30. USer Edits
  14. Build the project after doing all the above changes and program on the WBZ351 Curiosity Board.
    Figure 7-31. Clean and Build MPLAB Project
    Figure 7-32. Program/Flash the Firmware to Device
  15. P2P PHY application MCC configurations: The Harmony3 based P2P PHY application framework allows users to configure different settings and generate code based on those configurations.
    1. Application Configuration: The user can configure application/PHY specific settings like channel, source short address, IEEE® address, and more here. The IEEE 802.15.4 PHY supports 16 channels (channel 11 to 26) in the 2.4 GHz frequency band. These configuration changes appear in the app_p2p_phy_config.h file.
    Figure 7-33. Application Configuration File