This blog describes the Bluetooth Low Energy Stack enablement for the Freescale Freedom development platform with the Kinetis KW41Z dual wireless mode system-on-chip (SoC). The Software Development Package provides a Bluetooth Low Energy v4.2-compliant host stack and controller implementation with a set of GATT-based profiles and services implemented on top. MKW41Z Connectivity Software covers: BLE, Thread, GENFSK, IEEE802.15.4 and SMAC.
The main target platform is the FRDM-KW41ZFRDM-KW41Z Freedom platform based on the KW41Z wireless dual-mode SoC which incorporates an ARM Cortex-M0 core which can be configured to operate at various frequencies up to 48 MHz It has 512 KB of Flash and 128 KB of SRAM The platform features a composite USB device called OpenSDA which serves as debugger interface and as a USB-to-serial converter via a virtual COM port application
The Wireless UART application implements both the GATT client and server for the custom Wireless UART profile and services.
• Wireless UART Service (UUID: 01ff0100-ba5e-f4ee-5ca1-eb1e5e4b1ce0)
• Battery Service v1.0
• Device Information Service v1.1
The Wireless UART service is a custom service that implements a custom writable ASCII Char characteristic (UUID: 01ff0101-ba5e-f4ee-5ca1-eb1e5e4b1ce0) that holds the character written by the peer device.
The application behaves at first as a GAP central node. It enters GAP Limited Discovery Procedure and searches for other Wireless UART devices to connect. If the node fails to find any peripherals within seconds, it changes its role to a GAP peripheral. It enters GAP General Discoverable Mode and waits for a GAP central node to connect.
The application is built to work with another FRDM-KW41ZFRDM-KW41Z platform running the same example or with the Wireless UART from the Kinetis BLE Toolbox application We will be testing with two FRDM-KW41ZFRDM-KW41Z board here in next part of my blog i will demonstrate using one KW41Z board Kinetis BLE Toolbox
Preliminaries:
1. Download KW41Z Connectivity Software:
The KW41Z Connectivity Software package integrates the Kinetis Software Development Kit v2.0 and all the wireless connectivity stacks required to develop your solution using IEEE 802.15.4 and/or Bluetooth Low Energy.
Click HERE to download the KW41Z Connectivity Software appropriate for your computer's operating system.
After installation you can find Connectivity Example Codes at below folder location:
C:\NXP\MKW41Z_ConnSw_1.0.2
2. Install Your Toolchain:
NXP offers a complimentary toolchain called Kinetis Design Studio (KDS)
https://nxp.flexnetoperations.com/control/frse/download?element=7490587
The KW41Z Connectivity Software includes support for other tools such as IAR
(https://www.iar.com/iar-embedded-workbench/freescale/)
Steps involved:
1) Cloning a project: run the Project Cloner application
2) Building the Binaries using KDS
3) Executing the project using generated binaries
Cloning a project
I will be using Wireless UART application here for demonstration:
Navigate to the KW41Z Connectivity Software installation folder and run the Project Cloner application (C:\nxp\MKW41Z_ConnSw_1.0.2\tools\wireless\ProjectCloner).
Select the below options for project cloner
After the Codebase path has been selected correctly, the Project Cloner will display all the Connectivity Software example applications.
Next select the example application to be cloned (Clone example app), and the desired configuration (Clone Configuration).
By default both IAR and KDS projects are shown in the Clone configuration dropdown menu. I have selected for KDS tool chain
IMP Note: you need to do a clean build of a project BEFORE you clone it to create the debug folder and files like MKW41Z512xxx4_connectivity.ld in the original
I have changed the destination root path to “C:\Users\brao\Desktop\KW41-clonned project” and given the cloned project name as “Bluetooth-wireless uart cloned”
Now click on Clone Project
You can see the clonning successfully in log window: You can see the cloned project in folder
“C:\Users\brao\Desktop\KW41-clonned project\Bluetooth-wireless uart clonned\boards\frdmkw41z\wireless_examples\bluetooth\wireless_uart”
Step-2: Building the Binaries using KDS
Open the KDS tool and import the cloned project as shown below
Import the project into Workspace: File -> Import -> General -> Existing Projects into Workspace
Browse for the cloned project path:
“C:\Users\brao\Desktop\KW41-clonned project\Bluetooth-wireless uart cloned”
The KDS project window looks as shown below:
Build the Wireless uart project
Right Click on project folder and select Build Project as shown below:
Once it gets build you can see the status as Build Finished in console window
Step-3: Executing the project using generated binaries
Click the “Debug” button to flash the executable onto the board
There are two project configurations (build targets) supported for each KSDK project:
Debug – Compiler optimization is set to low, and debug information is generated for the executable. This target should be selected for development and debug.
Release – Compiler optimization is set to high, and debug information is not generated. This target should be selected for final application deployment.
Choose the appropriate build target, "Debug" or "Release", by clicking the downward facing arrow next to the hammer icon, as shown below. For this example, select the "Debug" target.
Note: Please make sure that you install the latest J-Link driver and associate it with KDS. To do this, download the driver from https://www.segger.com/jlink-software.html and install it.
Connect your board-1 FRDM-KW41ZFRDM-KW41Z to your system and proceed to Debug configuration settings
The projects are configured to use “J-Link / J-Trace” as the default debugger. Please make sure that your board’s OpenSDA chip contains a J-Link firmware or that the debugger selection corresponds to the physical interface used to interface to the board.
Open a putty or tera term hyperterminal application and open a session to your FRDM-KW41ZFRDM-KW41Z COM port(in my case com port connected is to com44
Configure the terminal with these settings:
115200 baud rate
No parity
8 data bits
1 stop bit
Start the application by clicking the "Resume" button:
You can see the execution of this board, the start Screen is blank after Resume is pressed
Now click on stop button as shown below:
Now connect the board-2 KW41Z from different usb port, and you can see the two board com ports as shown below:
Now connect the board-2 and perform the same operation of executing the debugging activity so that the program is flashed to the second board (board-2).
The board-2 is connected to com76 port in this case
Select the second J-Link board which represents the board-2 connected as active debugging session for the tool:
Open a hyperterminal with com76 port settings now you will be having 2 terminals open with wireless uart program executing on it.
Press the SW4 button on the first board to start scanning for devices.
Do the same on the second board.
After 3 seconds, the first board enters GAP General Discoverable Mode and the second board connects.
As soon as the LED3 turns solid on both devices, the user can start writing in one of the consoles.
The text appears on the other terminal, as shown in the figure below.
The Video output execution is shown in below video
Happy Executing Wireless UART using BLE method on KW41Z (wireless MCU)...