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 Boards | 2 |
Micro USB cable | 2 |
Personal Computer | 1 |
QT7 Xplained pro | 1 |
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.
-
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.
-
Program another WBZ351 Curiosity board with
csc_sleep_touch
application. Follow the steps mentioned below to program the curiosity board withcsc_sleep_touch
application.
Programming the hex file using MPLABX IPE
-
Precompiled Hex file is located in
<Harmony Content Path>\wireless_apps_pic32cxbz3_wbz35\apps\zigbee\
foldercsc_sleep_touch
-
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
-
Install MPLAB X IDE
-
Install XC32 Compiler
-
Install MCC Plugin
Open, Build and Program an existing application example
-
Connect Curiosity Board to the PC using usb cable
-
Open MPLAB X IDE
-
Select File > Open Project
-
Browse to project location:
<Harmony content path>\wireless_apps_pic32cxbz3_wbz35\apps\zigbee\csc_sleep_touch\\firmware
Attention Information related to the workings of the application example are available in
readme.md
file available in thecsc_sleep_touch
folder -
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
-
-
Select XC32 compiler
-
Select option Build Project in IDE to compile the application example
-
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 Light | Router | Device capable of controlling and monitoring other devices. It is typically a mains-powered device like a personal computer |
csc_sleep_touch | End Device | Reports 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.
Joining csc_sleep_touch with WBZ351Extended Light Router
# Hardware & Software Setup
-
Supply power to WBZ351 Curiosity Board consisting of Extended Light application by connecting a USB cable.
- 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
-
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))
-
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.
-
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.
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.
-
Create a new MCC Harmony Project. For more details, refer to 2.5 Creating a New MCC Harmony Project.
-
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
-
After the inclusion of the dependent components, the final project graph looks like
- Add “Touch” device type to the project
and accept all the dependenciesHardware 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.No Resistor to be Removed from WBZ351 Curiosity Board for Touch Functionality 1 R3 (PB4 –> Touch Button2) 2 R91 (PB1 –> CVD5 TouchSlider Y-Line3) 3 R92 (PB0 –> CVD4 RED LED ) 4 R93 (PB2 –> CVD6 TouchSlider Y-Line4) 5 R95 (PB5 –> CVD1 TouchSlider Y-Line2 & BLUE LED) 6 R99 (PB1 –> CVD5 TouchSlider Y-Line3) Click here for GREEN LED Control from QT7 Touch Button/Slider
-
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. -
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.