6.4 Creating a New MCC Harmony Project

  1. To create a new project, open MPLAB X IDE and click on File>New Project.
    Figure 6-1. New Project
  2. In the “New Project” pop-up, click on Microchip Embedded>Application Project(s)>Next.
    Figure 6-2. Choose Project
  3. In Select Device window, select the device from drop down and click Next.
    Figure 6-3. Select Device
  4. In Select Compiler window, Select the latest compiler and click Next.
    Figure 6-4. Select Compiler
  5. In Select Project Name and Folder window, enter the project name and select the project location, and click Finish.
    Figure 6-5. Select Project Name and Folder
  6. Now MPLAB X Code Configurator Content Manager will be launched automatically. It will setup the configuration and initiate the project.
    Figure 6-6. MCC Required Content
    1. After a while, MCC will display the project graph containing the default component: CMSIS Pack, System, Device Family Pack and EVSYS.
      Figure 6-7. Project Graph
    2. Project and Device resources.
      Figure 6-8. Project and Device resources
  7. Select IEEE 802.15.4 PHY APP available in “Libraries/Harmony/Wireless/System Services/” under the “Device resource” tab. All the necessary components will be auto populated. Accept all Dependencies or satisfiers, by selecting Yes.
    Figure 6-9. MCC Project Creation - Project graph
    Figure 6-10. MCC Project Graph
    Figure 6-11. MCC Project Graph
  8. After the auto population of all the components, the following dependencies needs to be selected manually.
    • CONSOLE component should be manually connected to its consumer SYS COMMAND.
      Figure 6-12. MCC Project Graph
    • CONSOLE component should be connected to it's dependency component SERCOM0 UART.
      Note: SERCOM 0 UART is specific to PIC32-BZ6 curiosity board, other SERCOMs can be selected as per the device selection.
      Figure 6-13. MCC Project Graph
    • 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 6-14. MCC Project Graph
  9. The following image shows the complete graph required for the application generation. Verify if the Project Graph window has all the expected MCC configurations.
    Figure 6-15. MCC Project Graph
  10. The following figure shows the steps for configurations to be done prior to project generation.
    • System and FreeRTOS Configuration
      Figure 6-16. System Configuration
      Figure 6-17. FreeRTOS Configuration
    • SERCOM0 PAD configuration and Pin settings. configure the SERCOM0 as illustrated in the following figure
      Figure 6-18. SERCOM 0 Configuration
    • SYS CONSOLE BUFFER configuration can be chosen as per user preference. (recommended to have max value possible).
      Figure 6-19. Console Configuration
    • P2P PHY APP component configuration options (can be modified as per user preference).
      Figure 6-20. P2P PHY APP Configuration
  11. Generate Code by clicking on the “Generate” button available under MCC tab as shown in Figure 6-21.
  12. Files and Routines Automatically generated by MCC.
    Figure 6-21. MCC Project code Generation
    Figure 6-22. MCC Project code Generation
    • After generating the code from MCC tool by clicking Generate, below is the project folder structure.
    Figure 6-23. MCC Project code Generation

    The following code snippet shows modifications that need to be added in MCC generated files (lines to be modified are highlighted).

    • tasks.c file.

      Add the following modifications in tasks.c file in the places highlighted in the following figures.

      TaskHandle_t xSYS_CMD_Tasks;
      Figure 6-24. Application edits
      Figure 6-25. Application edits
      Note: The above modifications need to be done manually for H3 repos using Core package version 3.12.1 or below. For the next release version of 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 6-26. Application edits
  13. User Application Development.
    • Compile MCC auto generated project as shown in following figure.
      Figure 6-27. user edits
    • Addressing the mandatory error: User action required in app_user_edits.c. Click on the error message in the output window, it will redirect to app_user_edits.c file. Follow the steps mentioned in the app_user_edits.c and do the necessary changes. Then comment the #error message as below. Refer here for more details.
      Figure 6-28. User Edits
  14. Build the project after doing all the above changes and program on Curiosity board.
    Figure 6-29. Clean and Build MPLAB Project
    Figure 6-30. Program/Flash the firmware to Device
  15. P2P PHY Application MCC Configurations.
    • Harmony3 based P2P PHY Application framework allows, user to do different configurations and generate the code based on that configurations.
      1. Application Configuration
        • Application/PHY specific configurations like channel, source short address, ieee address, etc., can be configured here. IEEE 802.15.4 PHY supports 16 channels (channel 11 to 26) in 2.4 GHz frequency band. These configuration changes are reflected in app_p2p_phy_config.h file.
          Figure 6-31. Application configuration file