7.2.1 RFD Project Creation with MAC Component

Developing the Application from Scratch using MCC

  1. Create a new MCC Harmony Project. For more details, refer to the Creating a New MCC Harmony Project from Related Links.
  2. From the Device Resources tab, navigate to Harmony>Wireless>Drivers>IEEE 802.15.4>IEEE 802.15.4 MAC.
  3. Click the plus symbol (+) to add the IEEE 802.15.4 MAC component (see the following figure).
    Figure 7-29. RFD Project - IEEE 802.15.4 MAC Component
    Note: The Device Resources tab displays IEEE 802.15.4 PHY and MAC components only if you clone the wireless_15_4_phy and wireless_15_4_mac repository in the MCC framework path.
  4. Upon selection, the user receives a prompt for auto-activation and auto-connect request of different component dependencies. Click Yes to add all the dependent components and also for all attachment auto-connect requests.
  5. Right click the TIME module for selecting the timer source.
    1. The user can select any of the timer source. For example, go to Available Satisfiers>TC0 (tc0).
    and select any one of the timer.
    Figure 7-30. RFD Project - Timer Component
  6. Click the TIME Component. Open Configuration Options tab and perform the following steps:
    1. Change the “Number of Clients” 5 to 10 based on software timers.
      Note: If the number of clients is less than 5, there is no need to change the timers.
      Figure 7-31. RFD Project - Number of Clients
  7. Click the IEEE 802.15.4 MAC component. Open Configuration Options tab and perform the following steps:
    1. In “Device Type Configuration” field, select RFD from the drop-down list for RFD project generation.
      Note: If security required, from “MAC Security Config” drop-down list, select Enabled.
      Figure 7-32. RFD Project - IEEE 802.15.4 MAC Device Type Configuration
  8. In case of selecting RFD as the MAC device type, an Enable Deep Sleep option appears in the configuration.
    1. If the application requires sleep functionality (for power saving), check the Enable Deep Sleep option. Click Yes to add all the dependent components and also for all attachment auto-connect requests.
    Note: The user can check the Project Graph to confirm that MCC has added all necessary modules for sleep support.
    Figure 7-33. RTC Components Auto-activation Confirmation Window
  9. Double-click Device Support in the Project Graph. In the Configuration Options tab, perform the following steps:
    1. Check Enable PMU Mode Setting to enable the setting.
    2. From the “PMU Mode” drop-down list, select PMU_MODE_BUCK_PWM.
    Figure 7-34. RFD Project - PMU Mode Setting
  10. Go to Plugins > Clock Configuration.
    Figure 7-35. MAC Clock Configuration Plugin
    1. The user must follow the images or instructions provided to set up the clocks as required.
      Figure 7-36. MAC Clock Configuration – SPLLPOSTDIV1
      Figure 7-37. MAC Clock Configuration – SOCEN, VBKP_32KSEL, and LPCLK_MOD
  11. If console prints is required, user can add a “CONSOLE” component to facilitate application console prints.
    1. In the Device Resources tab, navigate to Libraries>Harmony>System Services.
    2. Click the plus symbol (+) to add CONSOLE component (see the following figure).
      Figure 7-38. Adding CONSOLE Component
    3. In the project graph, right click on Console Driver . Navigate to Console Driver >Satisfiers>SERCOM0 to add and connect the SERCOM0 component.
      Figure 7-39. Console Drivers – SERCOM0 (sercom0)
    4. Click on the SERCOM0 component. Open Configuration Options tab and perform the following steps:
      1. Set “TX Ring Buffer Size” and “RX Ring Buffer Size” to 256.
      2. Change “Receive Pinout” and “Transmit Pinout”.
      Figure 7-40. SERCOM0 Configurations
    5. Configure the SERCOM0 to enable the direct high speed by performing the following steps:
      1. In “Project Graph” window, click the System component to open Configuration Options tab.
      2. To locate “SERCOM0 Direct (High Speed) Pin Enable (SCOM0_HSEN)”, navigate to System>Device & Project Configuration>PIC32WM_BZ6204 Device Configuration>Generate Fuse Settings>DEVCFG1
      3. From “SERCOM0 Direct (High Speed) Pin Enable (SCOM0_HSEN)” drop-down list, select DIRECT.
      Figure 7-41. System Configuration - SCOM0_HSEN Pin
  12. In the Device Resources tab, click the plus symbol (+) to add PIC32WM BZ6 Curiosity BSP.
    Figure 7-42. Device Resources - Board Support Packages
  13. Click Generate to generate code. The system adds the MAC files to the project upon code generation. For more details on code generation, refer to the MPLAB Code Configurator (MCC) Code Generation from Related Links.
    Figure 7-43. Code Generation

RTOS task for MAC Layer will be created and WPAN_Init() will be called from SYS_Initialize() function. Change argument of SYS_Load_Cal () function to WSS_ENABLE_ZB in initialization.c file.

Copy the demo_app_rfd folder from Project repository (wireless_apps_pic32_bz6/apps/ieee_802_15_4 / MAC/ push_pull_mac_app/demoapp_rfd/firmware/src/) into created project folder (../firmware/src/)

Include demoapp rfd folder as corresponding RFD project of Header files.

For including demoapp rfd header files in project

After selecting demoapp rfd folder, it will show as below image. And click on Add.

Include demoapp rfd folder as corresponding RFD project of Source files.

For including demoapp rfd source files in project -

After selecting demoapp rfd folder, it will show as below image now click on Add.

Added Demo no beacon app RFD Application files

Open Configuration for adding include header files directories.

Select XC32-gcc => Select Preprocessing and messages in option categories => Click on Include directories.

Browse and include demoapp rfd folder and click Apply and OK.

app.h file changes: add RFD APP message ID’s.

app.c file changes:

For channel configuration (example:CHANNEL_OFFSET :3 , Channel => 11 + 3 = 14)

If sleep enabled in RFD: add in selected line in app_idle_task.c. Device deep sleep in RFD demo is handled directly from APP task, so there is no need for calling vPortSuppressTicksAndSleep(). This is application specific change.

Right click on the project and Click on Clean and Build