"IoT Made Easy!"
Devices: | PIC32CXBZ2 | WBZ451HPE |
Features: | BLE | E-PAPER |
THE SOFTWARE ARE PROVIDED "AS IS" AND GIVE A PATH FOR SELF-SUPPORT AND SELF-MAINTENANCE. This repository contains example code intended to help accelerate client product development.
For additional Microchip repos, see: https://github.com/Microchip-MPLAB-Harmony
Checkout the Technical support portal to access our knowledge base, community forums or submit support ticket requests.
- Introduction
- Bill of materials
- Hardware Setup
- Software Setup
- Harmony MCC Configuration
- Board Programming
- Run the demo
This application demonstrates the use of an E-Paper Bundle 2 Display interfaced with WBZ451HPE Curiosity Board using Serial Peripheral Interface (SPI) protocol. WBZ451HPE Curiosity board receives data from Microchip Bluetooth Data (MBD) application through Bluetooth Low Energy (BLE) using TRANSPARENT BLE UART and sends the received data to E-PAPER Display.
The E-Paper 2.13" display is based on Active Matrix Electrophoretic Display (AMEPD) technology and has an integrated pixel driver, which uses the SPI interface to communicate with the host MCU.
TOOLS | QUANTITY |
---|---|
WBZ451HPE Curiosity Board | 1 |
E-Paper Bundle 2 | 1 |
- Connect the E-Paper Bundle 2 with the WBZ451HPE CURIOSITY BOARD using the below table.
WBZ451HPE | E-PAPER | Description | WBZ451HPE | E-PAPER | Description |
---|---|---|---|---|---|
AN | NC | NC | PWM | 16(D/C) | Data/Command |
RST | 2(RST) | RESET | INT | 15(BSY) | BUSY |
CS | 3(CS) | CHIP SELECT | RX | NC | NC |
SCK | 4(SCK) | SPI CLOCK | TX | NC | NC |
MISO | NC | NC | SCL | NC | NC |
MOSI | 6(MOSI) | SERIAL DATA INPUT | SDA | NC | NC |
3.3V | 7(3.3V) | POWER SUPPLY | 5V | NC | NC |
GND | 8 (GND) | GROUND | GND | 9 (GND) | GROUND |
Note: Remove the R169 0ohm resistor from the WBZ451HPE Curiosity Board!! |
---|
-
- Version: 6.20
- XC32 Compiler v4.45
- MPLAB® Code Configurator v5.5.1
- PIC32CX-BZ_DFP v1.4.243
- MCC Harmony
- csp version: v3.19.7
- core version: v3.13.5
- CMSIS-FreeRTOS: v11.1.0
- wireless_pic32cxbz_wbz: v1.4.0
- wireless_ble: v1.3.0
- wolfssl version: v5.4.0
- crypto version: v3.8.2
Tip | New users of MPLAB Code Configurator are recommended to go through the overview |
---|
Step 1 - Connect the WBZ451HPE CURIOSITY BOARD to the device/system using a micro-USB cable.
Step 2 - The project graph of the E-PAPER application is shown below.
Step 3 - In MCC harmony project graph, Add the SERCOM1 component under Libraries->Harmony->Peripherals->SERCOM->SERCOM1. select SERCOM1 and add "SPI" satisfiers by right click on the "⬦" near SPI to add the SPI component which will prompt an Auto-activation for "core"&"FreeRTOS" component, give yes to add the component and configure SERCOM1 and SPI as shown below.
Step 4 - In MCC harmony project graph, Add the BLE Stack from device resources under Libraries->Harmony->wireless->drivers->BLE and will prompt an Auto-activation for "Device_Support","PDS_SubSystem","NVM","Cryptographic","wolfcrypt Library" component, give yes to add the component and give yes to Auto-connect.
- In Device_Support add satisfiers by right click on the "⬦" in Device_Support->RTC to add the RTC component.
- Configure the BLE Stack as Shown below.
Step 5 - In MCC harmony project graph, select wolfCrypt Library and configure as mentioned below.
Step 6 - In MCC harmony project graph, Add Transparent profile from device resources under Libraries->Harmony->wireless->drivers->BLE->Profiles and configure as shown below.
- To add satisfiers as shown below right click on the "⬦" in Transparent profile->Transparent Services and add the satisfier "Transparent Services" to add the component as shown below.
Step 7 - In MCC harmony project graph, Add CONSOLE from Device Resources under Libraries->Harmony->System Services to add the "CONSOLE" component as shown below.
- To add satisfiers as shown above right click on the "⬦" in CONSOLE->UART and add the satisfier "SERCOM0" to add the component. Then select the SERCOM0 to configure as shown below.
Step 8 - In MCC harmony project graph, select system and configure as mentioned below.
Step 9 - In MCC harmony project graph, select Core and verify the mentioned below.
Step 10 - In MCC harmony project graph, select FreeRTOS and configure as mentioned below.
Step 11 - In project graph, go to Plugins->Pin configurations->Pin settings and set the pin configuration as shown below.
- Use these PIN Names while configuring.
CLICK_EINK_BUNDLE_CS
SERCOM2_SPI_SCK
SERCOM2_SPI_MOSI
SERCOM2_SPI_MISO
CLICK_EINK_BUNDLE_DC
CLICK_EINK_BUNDLE_RST
CLICK_EINK_BUNDLE_BSY
Step 12 - Generate the code.
Step 13 - From the unzipped folder copy the folder click_routines(which contains the eink_bundle.h, eink_bundle_font.h, eink_bundle_image.h, eink_bundle.c, eink_bundle_font.c, eink_bundle_image.c) to the folder firmware/src under your MPLAB Harmony v3 application project and add the Header (eink_bundle.h, eink_bundle_font.h, eink_bundle_image.h) and Source file (eink_bundle.c, eink_bundle_font.c, eink_bundle_image.c).
- In the project explorer, Right click on folder Header Files and add a sub folder click_routines by selecting “Add Existing Items from Folders…”
- Click on “Add Folder…” button.
- Select the “click_routines” folder and select “Files of Types” as Header Files.
- Click on “Add” button to add the selected folder.
- The eink bundle header files gets added to your project.
- In the project explorer, Right click on folder Source Files and add a sub folder click_routines by selecting “Add Existing Items from Folders…”.
- Click on “Add Folder…” button
- Select the “click_routines” folder and select “Files of Types” as Source Files.
- Click on “Add” button to add the selected folder
- The eink bundle source files gets added to your project.
- The click_routines folder contain an C source file eink_bundle.c. You could use eink_bundle.c as a reference to add E-Paper display functionality to your application.
Step 14 - Change the following Code as givien below.
- In your MPLAB Harmony v3 based application go to "firmware\src\app_user_edits.c", make sure the below code line is commented.
//#error User action required - manually edit files as described here.
-
In your MPLAB Harmony v3 based application go to "firmware\src\app.h" and do the following changes.
- Copy & Paste the Code in app.h
-
In your MPLAB Harmony v3 based application go to "firmware\src\app.c" and do the following changes.
- Copy & Paste the Code in app.c
-
In your MPLAB Harmony v3 based application go to "firmware\src\app_ble\app_ble_handler.c" and do the following changes.
-
Include the following code in Header.
#include "system/console/sys_console.h" #include "peripheral/sercom/usart/plib_sercom0_usart.h" #include "click_routines/eink_bundle/eink_bundle.h" #include "app.h" extern uint16_t conn_hdl;
-
Under the Switch Case "BLE_GAP_EVT_CONNECTED" add the following code.
APP_Msg_T appMsg; appMsg.msgId = APP_MSG_BLE_DISPLAY_EVT; appMsg.msgData[BLE_DATA_LINE] = BLE_TEXT_LINE1; appMsg.msgData[BLE_DATA_SIZE] = BLE_TEXT_STATUS_SIZE; memcpy(&appMsg.msgData[BLE_DATA], " CONNECTED ", BLE_TEXT_STATUS_SIZE); appMsg.msgData[DISP_DATA_OFFSET+BLE_TEXT_STATUS_SIZE+1]= '\0'; SERCOM0_USART_Write((uint8_t *)"Connected\r\n",11); conn_hdl = p_event->eventField.evtConnect.connHandle; OSAL_QUEUE_Send(&appData.appQueue, &appMsg, 0);
-
Under the Switch Case "BLE_GAP_EVT_DISCONNECTED" add the following code.
APP_Msg_T appMsg; appMsg.msgId = APP_MSG_BLE_DISPLAY_EVT; appMsg.msgData[BLE_DATA_LINE] = BLE_TEXT_LINE1; appMsg.msgData[BLE_DATA_SIZE] = BLE_TEXT_STATUS_SIZE; memcpy(&appMsg.msgData[BLE_DATA], "DISCONNECTED", BLE_TEXT_STATUS_SIZE); appMsg.msgData[DISP_DATA_OFFSET+BLE_TEXT_STATUS_SIZE+1]= '\0'; SERCOM0_USART_Write((uint8_t *)"Disconnected\r\n",14); conn_hdl = 0xFFFF; BLE_GAP_SetAdvEnable(0x01, 0); OSAL_QUEUE_Send(&appData.appQueue, &appMsg, 0);
-
-
In your MPLAB Harmony v3 based application go to "firmware\src\app_ble\app_trsps_handler.c" and do the following changes.
-
Include the following code in Header.
#includ#include "osal/osal_freertos_extend.h" #include "definitions.h" #include "click_routines/eink_bundle/eink_bundle.h"
-
Under the Switch Case "BLE_TRSPS_EVT_RECEIVE_DATA" add the following code.
uint16_t data_len = 0; uint8_t *ble_data = 0; // Retrieve received data length BLE_TRSPS_GetDataLength(p_event->eventField.onReceiveData.connHandle, &data_len); // Allocate memory according to data length ble_data = OSAL_Malloc(data_len); if(ble_data == NULL) break; // Retrieve received data BLE_TRSPS_GetData(p_event->eventField.onReceiveData.connHandle, ble_data); APP_Msg_T appMsg; appMsg.msgId = APP_MSG_BLE_DISPLAY_EVT; appMsg.msgData[BLE_DATA_LINE] = BLE_TEXT_LINE2; appMsg.msgData[BLE_DATA_SIZE] = data_len; memcpy(&appMsg.msgData[BLE_DATA], ble_data, data_len); appMsg.msgData[DISP_DATA_OFFSET+data_len+1]= '\0'; OSAL_QUEUE_Send(&appData.appQueue, &appMsg, 0); // Free memory OSAL_Free(ble_data);
-
Step 15 - Clean and build the project. To run the project, select "Make and program device" button.
Step 16 - To the test the application in MBD app follow the steps provided below and the link for the TRANSPARENT BLE UART.
Note: For Android App Select BM70 instead of PIC32CXBZ in the step 2 as mentioned above !! |
---|
- The Precompiled hex file is given in the hex folder. Follow the steps provided in the link to program the precompiled hex file using MPLABX IPE to program the pre-compiled hex image.
The application folder can be found by navigating to the following path:
- "firmware\WBZ451_E_PAPER_BLE_UART.X"
Follow the steps provided in the link to Build and program the application.
- After programming the board, the expected application behavior is shown in the below video.