"IoT Made Easy!"
Devices: | PIC32CXBZ3 | WBZ35x |
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 WBZ351 Curiosity Board using Serial Peripheral Interface (SPI) protocol. WBZ351 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 |
---|---|
PIC32CX-BZ3 and WBZ35x Curiosity Board | 1 |
E-Paper Bundle 2 | 1 |
- Connect the E-Paper Bundle 2 with the PIC32CX-BZ3 and WBZ35x Curiosity Board using the below table.
WBZ351 | E-PAPER | Description | WBZ351 | E-PAPER | Description |
---|---|---|---|---|---|
AN | NC | NC | PWM | 2(RST) | RESET |
RST | NC | NC | INT | NC | NC |
CS | 3(CS) | CHIP SELECT | RX | NC | NC |
SCK | 4(SCK) | SPI CLOCK | TX | NC | NC |
MISO | NC | NC | SCL | 16(D/C) | Data/Command |
MOSI | 6(MOSI) | SERIAL DATA INPUT | SDA | 15(BSY) | BUSY |
3.3V | 7(3.3V) | POWER SUPPLY | 5V | NC | NC |
GND | 8 (GND) | GROUND | GND | 9 (GND) | GROUND |
Note: PIN 2 (RST) , 15 (BSY) & 16 (D/C) of E-PAPER should be connected with PWM, SDA & SCL of WBZ351 Respectively !! |
---|
-
- Version: 6.20
- XC32 Compiler v4.45
- MPLAB® Code Configurator v5.7.1
- PIC32CX-BZ3_DFP v1.2.183
- MCC Harmony
- csp version: v3.19.7
- core version: v3.13.5
- CMSIS-FreeRTOS: v10.5.1
- CMSIS_5: v5.9.0
- wireless_pic32cxbz_wbz: v1.4.0
- wireless_ble: v1.3.0
Tip | New users of MPLAB Code Configurator are recommended to go through the overview |
---|
Step 1 - Connect the WBZ351 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" component, give yes to add the component and give yes to Auto-connect.
- Configure the BLE Stack as Shown below.
Step 5 - 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 6 - 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 7 - In MCC harmony project graph, select system and configure as mentioned below.
Step 8 - In MCC harmony project graph, select Core and verify the mentioned below.
Step 9 - In MCC harmony project graph, select FreeRTOS and configure as mentioned below.
Step 10 - In project graph, go to Plugins->Pin configurations->Pin settings and set the pin configuration as shown below.
- Use these PIN Names while configuring.
USER_LED
CLICK_EINK_BUNDLE_CS
CLICK_EINK_BUNDLE_DC
CLICK_EINK_BUNDLE_RST
CLICK_EINK_BUNDLE_BSY
Step 11 - Generate the code.
Step 12 - 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 13 - Change the following Code as givien below.
- In your MPLAB Harmony v3 based application go to "firmware\src\app_user_edits.c", implement the changes mentioned and 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.
USER_LED_Clear(); SERCOM0_USART_Write((uint8_t *)"Connected\r\n",11); conn_hdl = p_event->eventField.evtConnect.connHandle;
-
Under the Switch Case "BLE_GAP_EVT_DISCONNECTED" add the following code.
USER_LED_Set(); SERCOM0_USART_Write((uint8_t *)"Disconnected\r\n",14); conn_hdl = 0xFFFF; BLE_GAP_SetAdvEnable(0x01, 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; memcpy(&appMsg.msgData, ble_data, data_len); appMsg.msgData[data_len+1]= '\0'; OSAL_QUEUE_Send(&appData.appQueue, &appMsg, 0); // Free memory OSAL_Free(ble_data);
-
Step 14 - Clean and build the project. To run the project, select "Make and program device" button.
Step 15 - 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:
- "WBZ351_E_PAPER_BLE_UART/WBZ351_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.