Freedom KL25Z from Freescale Semiconductor is a popular board based on KL25 ARM Cortex M0+ micro-controller. There are many tutorials and examples available for using many features of the FRDM-KL25Z board. This blog describes the implementation of USB host interface to support a low cost Bluetooth dongle along with 3-axis accelerometer and PWM features.

In the demo, an Android application will connect to the Bluetooth device connected to the FRDM board. After connection, the board will transmit its accelerometer reading to the application which will be used to render a 3D image of the board. Similarly the application can be used to drive the tri-color LED available with varying colors using PWM.
This blog will describe the hardware for the demo along with the necessary software implementation that can be customized for user’s applications such as for IoT, academics etc.
Bluetooth Stack over USB

Bluetooth connectivity for FRDM-KL25Z

Hardware Setup

Interfacing the Bluetooth USB dongle to the board is the important step for the demo. To enable using low cost devices, the demo uses low cost dongles available in local stores under 2 dollars. These devices generally uses CSR chipset module inside.

About connecting the dongle to the board, follow the procedure outlines in this MCUOnEclipse blog.

This link provides the detailed description of USB host mode hack for the FRDM KL25Z board. Another option is to modify header “J21” (Refer sheet3 in Freedom KL25Z schematics with document number SCH-27556 or SPF-27556).

For 3 Axis accelerometer support, the on-board MMA8451Q chip is used. It is connected to KL25 MCU via I2C interface. I2C0 port in pins PTE24 and PTE25 is used for the interface.

The on-board tri-color LED is utilized for PWM implementation. The Red LED of tri-color LED is connected to the PWM pin TPM2_CH0 of PTB18, Green LED is connected to TPM2_CH1 of PTB19 and blue LED is connected to TPM0_CH1 of PTD1.

S.NO Signal Name Pin Number
1 I2C0_SDA PTE25
2 I2C0_SCL PTE24
3 Red LED PTB18
4 Green LED PTB19
5 Blue LED PTD1

For this demo, the power to the board is provided through the openSDA USB Mini-B connector “J7”.

Software

The firmware initially prepares all the underlying hardware interfaces. The USB stack first prepares the USB OTG controller for host operation. Once done, it enumerates the attached device. Once a valid Bluetooth Dongle is detected, it configures the same and brings up the various layers of the Bluetooth stack like HCI, L2CAP, RFComm etc. Once a logical channel is established between the FRDM-KL25 board and dongle, the data is transferred in a custom format.

Upon detection of change in accelerometer reading, the 3 axis data is read and sent to the Android application over Bluetooth by adding a header field in the front and footer in the end. Up on recognizing the packet, the application calculates the position and renders the 3D image of the board in the display using OpenGLES routines.

Similarly on change of LED colour values by the user, the data is send in custom frame format to the board over Bluetooth. The firmware decodes the same and drives the 3 components of the LED in different brightness values using PWM modulation.

Demo

The demo of Bluetooth Stack on FRDM-KL25Z is available as a video in the below link.

Source Code of the project

All the necessary firmware to run in the FRDM board can be downloaded from our downloads page.

With Bluetooth, especially Bluetooth Low Energy (BLE) is being used more and more in IoT applications like activity trackers, health bands etc, such a stack will be an advantage when integrating the functionality on top of USB host using low cost USB dongles.

About Embien Technologies: Embien Technologies is a leading provider of embedded design services for the Semi-conductor, Industrial, Consumer and Health Care segments. Our extensive experience in working with wireless technologies like Bluetooth, Bluetooth Low Energy (Bluetooth Smart), RFID, ZigBee, WiFi etc enables us provide solutions to customer quickly at an unmatched quality at a very low price point. Feel free to contact us for any of your connectivity, OpenGL, mobile application or embedded product development requirements.

Freedom KL25Z from Freescale Semiconductor is a popular board based on KL25 ARM Cortex M0+ micro-controller. There are many tutorials and examples available for using many features of the FRDM-KL25Z board. This blog describes the implementation of USB host interface to support a low cost Bluetooth dongle along with 3-axis accelerometer and PWM features.

In the demo, an Android application will connect to the Bluetooth device connected to the FRDM board. After connection, the board will transmit its accelerometer reading to the application which will be used to render a 3D image of the board. Similarly the application can be used to drive the tri-color LED available with varying colors using PWM.
This blog will describe the hardware for the demo along with the necessary software implementation that can be customized for user’s applications such as for IoT, academics etc.
Bluetooth Stack over USB

Bluetooth connectivity for FRDM-KL25Z

Hardware Setup

Interfacing the Bluetooth USB dongle to the board is the important step for the demo. To enable using low cost devices, the demo uses low cost dongles available in local stores under 2 dollars. These devices generally uses CSR chipset module inside.

About connecting the dongle to the board, follow the procedure outlines in this MCUOnEclipse blog.

This link provides the detailed description of USB host mode hack for the FRDM KL25Z board. Another option is to modify header “J21” (Refer sheet3 in Freedom KL25Z schematics with document number SCH-27556 or SPF-27556).

For 3 Axis accelerometer support, the on-board MMA8451Q chip is used. It is connected to KL25 MCU via I2C interface. I2C0 port in pins PTE24 and PTE25 is used for the interface.

The on-board tri-color LED is utilized for PWM implementation. The Red LED of tri-color LED is connected to the PWM pin TPM2_CH0 of PTB18, Green LED is connected to TPM2_CH1 of PTB19 and blue LED is connected to TPM0_CH1 of PTD1.

S.NO Signal Name Pin Number
1 I2C0_SDA PTE25
2 I2C0_SCL PTE24
3 Red LED PTB18
4 Green LED PTB19
5 Blue LED PTD1

For this demo, the power to the board is provided through the openSDA USB Mini-B connector “J7”.

Software

The firmware initially prepares all the underlying hardware interfaces. The USB stack first prepares the USB OTG controller for host operation. Once done, it enumerates the attached device. Once a valid Bluetooth Dongle is detected, it configures the same and brings up the various layers of the Bluetooth stack like HCI, L2CAP, RFComm etc. Once a logical channel is established between the FRDM-KL25 board and dongle, the data is transferred in a custom format.

Upon detection of change in accelerometer reading, the 3 axis data is read and sent to the Android application over Bluetooth by adding a header field in the front and footer in the end. Up on recognizing the packet, the application calculates the position and renders the 3D image of the board in the display using OpenGLES routines.

Similarly on change of LED colour values by the user, the data is send in custom frame format to the board over Bluetooth. The firmware decodes the same and drives the 3 components of the LED in different brightness values using PWM modulation.

Demo

The demo of Bluetooth Stack on FRDM-KL25Z is available as a video in the below link.

Source Code of the project

All the necessary firmware to run in the FRDM board can be downloaded from our downloads page.

With Bluetooth, especially Bluetooth Low Energy (BLE) is being used more and more in IoT applications like activity trackers, health bands etc, such a stack will be an advantage when integrating the functionality on top of USB host using low cost USB dongles.

About Embien Technologies: Embien Technologies is a leading provider of embedded design services for the Semi-conductor, Industrial, Consumer and Health Care segments. Our extensive experience in working with wireless technologies like Bluetooth, Bluetooth Low Energy (Bluetooth Smart), RFID, ZigBee, WiFi etc enables us provide solutions to customer quickly at an unmatched quality at a very low price point. Feel free to contact us for any of your connectivity, OpenGL, mobile application or embedded product development requirements.

Subscribe to our Blog