5.6.1.7 csc_sleep_touch with Touch Remote using Extended Light

WBZ351 Curiosity Board

Devices (Device): PIC32CX5109BZ31048 (MCU) on WBZ351 module

Peripherals (Used, On-Board): | UART-USB Converter|

Introduction

This tutorial will help users to create a low power enabled color sense controller integrated with Touch application which can get connected with a Extended Light and report the touch values.

GitHub Repository

The firmware, .hex, and accompanying readme.md file for the application can be found in the GitHub repository – csc_sleep_touch

Prerequisites :

Hardware Required

Tool Qty
WBZ351 Curiosity Boards2
Micro USB cable2
Personal Computer1
QT7 Xplained pro1

SDK Setup

- Getting Started with Software Development

Terminal Software

- TeraTerm

Programming the precompiled hex file or Application Example

The Color Sense is an end device application. The Color Sense application works by getting connected with a router device (Extended Light). So, to successfully execute this demo, it is mandatory to have a extended light application set up prior to running the color-sense application.

  1. First program the WBZ351Curiosity board with Extended Light which can act as Zigbee Gateway/Router. The details regarding the extended light application including programing steps is provided TBD(Provide the link to Extended Light page). Gather the information regarding the extended light application, and program the application to one of the curiosity board.

  2. Program another WBZ351 Curiosity board with csc_sleep_touch application. Follow the steps mentioned below to program the curiosity board with csc_sleep_touch application.

Programming the hex file using MPLABX IPE

  1. Precompiled Hex file is located in <Harmony Content Path>\wireless_apps_pic32cxbz3_wbz35\apps\zigbee\csc_sleep_touch folder

  2. To flash the hex file using IPE, follow the steps mentioned here

Caution: Users should choose the correct Device and Tool information

Programming the Application using MPLABX IDE

Follow the steps below to run a precompiled application example.

Prerequisites

  1. Install MPLAB X IDE

  2. Install XC32 Compiler

  3. Install Device Family Part Pack

  4. Install MCC Plugin

  5. Install Harmony 3 Dependencies

Open, Build and Program an existing application example

  1. Connect Curiosity Board to the PC using usb cable

  2. Open MPLAB X IDE

  3. Select File > Open Project

  4. Browse to project location: <Harmony content path>\wireless_apps_pic32cxbz3_wbz35\apps\zigbee\csc_sleep_touch\\firmwareInformation related to the workings of the application example are available in readme.md file available in the csc_sleep_touch folder
  5. Open Project Properties

    • Select WBZ351 Curiosity Board as hardware tool for programming

    • Ensure correct DFP is selected as mentioned in the Tools and Harmony Components

  6. Select XC32 compiler

  7. Select option Build Project in IDE to compile the application example

  8. Select option Run Project in IDE to program the target – the onboard debugger will program the example application

<Harmony Content Path> how to find what is my Harmony Content Path.

Demo Description

This application demonstrate the working of Zigbee csc_sleep_touch end device joining to Zigbee Router (Extended Light) . After joining, csc_sleep_touch device will start ZCL attribute reporting of LEDs ON/OFF, and LED Brightness Level.

Application Zigbee Logical Device Type Functionality
Extended LightRouterDevice capable of controlling and monitoring other devices. It is typically a mains-powered device like a personal computer
csc_sleep_touchEnd DeviceReports sensor data such as LED ON/OFF, and LED Brightness Level.

The application demonstration required to have a extended light application up and running in the vicinity. which can act as Zigbee Gateway/Router. The Color Sense Controller application here can act as Zigbee end device.

Demo Steps: Commissioning0.

The Zigbee csc_sleep_touch can be connected to a zigbee network.

Note: Color Sense Controller does not have console log so just program color sense to the curiosity351 board and open tera term for extended light for the connection establishment as shown below.

Joining csc_sleep_touch with WBZ351Extended Light Router

# Hardware & Software Setup

  1. Supply power to WBZ351 Curiosity Board consisting of Extended Light application by connecting a USB cable.

  2. The application activity is shown as “Console Log” through on-board UART-USB converter
    • Open Terminal(Example: Tera Term) with the setup as shown below to see the log
    • On the PC side virtual COM port connection that corresponds to the board shall have following settings:
      • BAUD RATE: 115200 (as configured in SERCOM configuration)
      • PARITY: None
      • DATA BITS: 8
      • STOP BITS: 1
      • FLOW CONTROL: None
      Additionally, local echo and sending line ends with line feeds shall be enabled in the PC serial terminal application.
  3. Make the serial terminal ready and then press the reset button on the curiosity board. Below log will be displayed.

# Network Formation (Router - (Extended Light))

  1. Once the board is powered on and serial terminal setup is done, the board is ready to be operated as a router. It is responsible for initially forming the network and then, via the Trust Centre functionality, managing which other devices are allowed to join the network and distributing security keys to those that are allowed to join.

  2. Input command : resetToFN and look for the below logs for successful zigbee network formation on CI. It will open up the network for other zigbee devices to join for first 180 seconds from the first power ON.

  • Case1: If a near by device is trying to join a network, and sees Extended Light then will join the network as shown in below log.

    The commissioning procedure will last for 180 seconds. In case no other devices are there in vicinity and at the end of 180 seconds, the below log will be displayed

    Once after the Commissioning Procedure is complete press QT7 Button2 to ON/OFF the Green LED use slider to control the Brightness of the LED. Log's will be displayed as below under the Extended Light Tera Term Console.

Developing this Application from scratch using MPLAB Code Configurator

This section intended to showcase the complete application development from the scratch including the individual component and its dependency inclusion.

Tip: New users of MPLAB Code Configurator are recommended to go through the overview.
  1. Create a new MCC Harmony Project. For more details, refer to 2.5 Creating a New MCC Harmony Project.

  2. Add “Color Sense Controller” device type to the project and accept all the dependencies

    Accept all the component auto-activation and attachment auto-connect confirmation.

    Confirm “Yes” for the Attachment Auto-Connect requests

  3. After the inclusion of the dependent components, the final project graph looks like

  4. Add “Touch” device type to the project and accept all the dependencies
    Hardware Used:
    • QT7 Xplained Pro kit is an extension board here
    Steps to be followed for Touch Configuration:
    • Click here for QT7 Touch Configuration
    Note: In order to use Touch CVD Peripheral with WBZ351 Curiosity Board remove the below mentioned Resistors in order to make Touch work. The Impact of the removed resistor will affect the Red & Blue functionality, only Green LED is used for the demo purpose.
    Table 5-16. 
    S.NoResistor to be Removed from WBZ351 Curiosity Board for Touch Functionality
    1R3 (PB4 –> Touch Button2)
    2R91 (PB1 –> CVD5 TouchSlider Y-Line3)
    3R92 (PB0 –> CVD4 RED LED )
    4R93 (PB2 –> CVD6 TouchSlider Y-Line4)
    5R95 (PB5 –> CVD1 TouchSlider Y-Line2 & BLUE LED)
    6R99 (PB1 –> CVD5 TouchSlider Y-Line3)

    Click here for GREEN LED Control from QT7 Touch Button/Slider

  5. System Clock Configuration and SOSC selection during sleep mode

    System Clock Selection

    SOSC Clock Configuration

    Note: Even after enabling and selecting the SOSC as backup source in the clock configuration. The LPCLK and RTC clock still show as 0Hz. This is a known issue which will be resolved in upcoming MCC release. For the time being, to fix this issue, a manual application code modification is necessary. The required change will be discussed in the next section.
  6. Generate Code

    Now all the required components has been added to the project and necessary configuration modification is made. The next step is to generate the application code.

Manual Application code edit

This section talks about the mandatory code modifications that needs to be incorporated inorder to implement the sleep mode functionality.

Step 1: app_user_edits.c

  • Some of the Harmony 3 generated files cannot be fully configured by the MPLABX Code Configurator. This file contains the instructions for the user to modify these files.

    Follow the instruction mentioned on the app_user_edits.c file and after completing the required edits, comment out or remove the #error line

Step 2: plib_gpio.c

  • Code Changes for Sleep functionality

    Add the below code inside the GPIO_Intitialize function

    void GPIO_Initialize ( void )
    {
     /* Disable JTAG since at least one of its pins is configured for Non-JTAG function */
        CFG_REGS->CFG_CFGCON0CLR = CFG_CFGCON0_JTAGEN_Msk;    
    //All pubs are defined as input after a reset.
        GPIOA_REGS->GPIO_TRISSET = 0xFFFF; //Set all pins as input
        GPIOA_REGS->GPIO_CNPUSET = 0x7FF3; //Except PA2 (QSPI Data), PA3, the others are pulled up
        GPIOA_REGS->GPIO_CNPDSET = 0x0008; //RPA3 is Pulled down: SERCOM 0-RTS
        /*  PB  */
        GPIOB_REGS->GPIO_ANSELSET = 0x0040; //PB6 ANSEL for Temp sensor
        GPIOB_REGS->GPIO_TRISSET = 0xFFFF;  //Set all pins as input
        GPIOB_REGS->GPIO_CNPUSET = 0x3D96;  //Pull up: PRB 1, 2, 4, 7, 8, 10, 11, 12 , 13
        GPIOB_REGS->GPIO_CNPDSET = 0x0029;  //Pull down RB0,3,5 for LED
              /* PORTA Initialization */
        /* PORTB Initialization */
        /* PPS Input Remapping */
        /* PPS Output Remapping */
    }
    
  • Step 3:Step 4 - Plib_rtc.h

    • Default Generated: #define RTC_COUNTER_CLOCK_FREQUENCY (0U / (1UL << (0x1U - 1U)))
    • Replace to: #define RTC_COUNTER_CLOCK_FREQUENCY (32768U / (1UL << (0x1U - 1U)))
  • Step 4: zigbeeAppDeviceSelect.h

    • Default Generated: #define CS_UID 0xbef //Unique Identifier (UID) determining the device extended address
    • Change to a unique value: #define CS_UID 0x123bee //Unique Identifier (UID) determining the device extended address
    Note: By default the Co-ordinator is also having same value. In a network the UID value should be unique.