Posts

LM53X User Guide

Introduction

Overview

This user guide explains how to use the LM930/ LM931 Bluetooth Smart Module on the LM53X development kit. A good starting point to developing your own user application firmware within the provided CSR µEnergy SDK. LM offer project support including developing new application firmware to meet your project requirements.

 

Out of the box

  • CSR toolchain (including CSR µEnergy SDK (xIDE))
  • LM930/ LM931 Bluetooth Smart module
  • LM53X (including the CSR USB-SPI Programmer Board)
  • USB to mini USB cable (Not Included)
  • Jumpers (x3)
  • CR2032 Coin Cell Battery

 

 

LM53X Hardware

Mounting the LM930/ LM931 to the LM53X

The LM930/ LM931 module is mounted in one of 2 ways to the LM53X:

  1. Soldered to the Pads on CN1 (for a permanent connection).
  2. Connected via 1.27 mm pitch pins that is soldered to CN1 (for a temporary connection).*

mounting-lm930-lm931

*Note: for connection (option 2) the pins need to be angled slightly inwards and ideally some soft foam can be placed under the Module (to ensure some upward force is applied to the module and a good connection is made between the module and the pins).

 

Powering the LM53X

The LM53X is powered in one of 3 ways:

  1. USB powered from the CSR USB-SPI Programmer Board (power switch positioned to the right in RED)

usb-powered-lm53x

This is a convenient powering option. Requiring a USB to mini USB cable to connect the programmer board to the development PC.

 

2. Battery Power (power switch positioned to the left in RED)

battery-powered-lm53x

The battery connector is situated underneath the board and accepts a CR2032 Coin Cell Battery.

This option is useful when the developer wants to test their software in a “real world” powered situation.

Note: No jumpers should be connected to CN3, CN4 and CN7.

 

3. Powered from Arduino board (power switch positioned to the right in RED)

arduino-powered-lm53x

This option allows the LM53X to be mounted directly on and powered by an Arduino Uno board.

The 4 edge connectors (Marked with yellow rectangles) needs to be mounted as if the LM53X is an Arduino “Shield” with the pins protruding from the bottom of the PCB.

 

Connecting External Devices

Connecting an Arduino Board

Note: Using an Arduino is optional.

The Arduino microcontroller is connected to the LM930/ LM931 via the LM53X. The LM930/ LM931 effectively becomes a slave device to the Arduino. LM53X is simply connected into the female headers of the Arduino, by soldering male pins under the LM53X. The same way an Arduino shield is connected. When the Arduino and the module are connected, power the LM53X in one of the three ways described in the previous section.

Note: The Arduino needs its own power supply.

The Arduino can program the module using either a SPI or a UART interface.

For SPI mode, the LM930/ LM931 SPI pins are always connected to the Arduino General I/O pins as follows:

Arduino Pins LM930/ LM931 Pins
PB1 (IOH2/IO9 on Shield) SPI_ENABLE (PIN 25)
PB2 (IOH3/IO10 on Shield) SPI_CS (PIN 18)
PB3 (IOH4/IO11 on Shield) SPI_MOSI (PIN 19)
PB4 (IOH5/IO12 on Shield) SPI_MISO (PIN 20)
PB5 (IOH6/IO13 on Shield) SPI_CLK (PIN 12)

 

For UART mode, the LM930/ LM931 UART pins (TX (PIN 8) & RX (PIN 9)) are connected to the Arduino I/O pins in one of two ways, with the CN3/ CN4 jumpers positioned either LEFT or RIGHT:

CN3/ CN4 Jumper Positions Arduino Pins LM930/ LM931 Pins
LEFT (shown in RED)jumper-position-left PB2 (IOH3/IO10 on Shield) TX (LM930/ LM931 PIN 8)
PB3 (IOH4/IO11 on Shield) RX (LM930/ LM931 PIN 9)
RIGHT (shown in RED)jumper-position-right RX0 (UART_RX (LM930/ LM931_TX)) IOL1/ IO0 TX (LM930/ LM931 PIN 8)
TX0 (UART_TX (LM930/ LM931_RX)) IOL2/ IO1 RX (LM930/ LM931 PIN 9)

 

Connecting Peripheral Devices

peripheral-device-lm53x

I2C is used to connect peripheral devices (e.g. sensors) to the LM930/ LM931 module via the LM53X. The peripheral device is connected to the corresponding female header holes (highlighted in YELLOW). When the module and peripheral devices are connected, power the LM53X in one of the three ways described in the previous section.

 

User Definable Switches and RGB LED

user-definable-io

The LM53X has two inbuilt switches and an RGB LED highlighted in RED. These are all user programmable, depending on the Bluetooth LE application been developed.

Two general purpose switches S1 and S2 are connected to P10_0/ UART_TX (Pin 8) and P10_1/ UART_RX (Pin 9) respectively.

A RGB LED has Red connected to LED_0 (Pin 22), Green connected to SDA (Pin 23) and Blue connected to SCL (Pin 24).

Use the PIO for any additional LEDs, switches and other I/O devices required

 

 

Bluetooth LE Firmware Development

Using the CSR µEnergy SDK

For modifying the provided LM demo application firmware and developing new application firmware, you must follow the steps below:

  1. Install CSR µEnergy SDK (xIDE) toolchain on the PC you are developing with. (The installation includes the SDK, support documentation and necessary drivers).
  2. Connect the LM930/ LM931 Bluetooth Smart module to CN1 of the LM53X development kit.
  3. Plug a jumper to CN7 of the LM53X development kit (this allows the LM53X development kit and LM930/ LM931 module to be powered from the connected PC).
  4. Plug the CSR USB-SPI Programmer Board to J1 header of the LM53X and then use the USB to mini USB cable to connect the CSR USB-SPI Programmer Board to the PC you are developing on.

setting-up-lm53x-with-sdk

 

Flashing a Demo Application Image

Demo applications are compiled and the resulting image is ready to be flashed into the LM930/ LM931 module EEPROM memory. This is interfaced with the MCU through the I2C bus.

Execute the following steps to flash the demo application image to the LM930/ LM931 memory using the CSR µEnergy SDK:

1/ Download the required LM demo application zip provided e.g. ‘Key Fob V1.0’. This includes the source files (.c, .h, etc.).

2/ Open the workspace of the demo application in the CSR µEnergy SDK by clicking the project tab and then ‘Open Workspace’.

open-project-screenshotopen-project-screenshot2

3/ Build the active project by clicking the build tab and then ‘Build Active Project’.

open-project-screenshot

4/ Download the application to the module by clicking the debug tab followed by ‘run’.

run-project-screenshot

 

Customising Demo Application Firmware

Demo applications are configured by changing the parameters and values according to the demo application behaviour. In every src folder there is a header file named user_config.h which contains configurable code definitions. Refer to the specific demo application file for more details as the definitions vary depending on the related application.

iBeacon example:

user-config-h-file-for-ibeacon-screenshot

The file below contains all the user customisable definitions:

user-config-h-file-for-ibeacon-screenshot2

After modifying desired definitions you compile the project again using the CSR µEnergy SDK. A new image file is created to be flashed into the memory by using the SDK. For more details about µEnergy SDK and the entire toolchain please refer to the CSR documentation and support.

 

Developing Application Firmware

For developing a new application refer to the CSR documentation provided with the SDK. The CSR µEnergy SDK allows you to develop new applications. That can be compiled and debugged seamless on the LM930/ LM931 module. The LM demo applications are a good starting point for new applications, saving the time required to develop an application from scratch.

It is necessary to modify the CS keys included in LM demo applications to fit your application requirements e.g. the BD address.

CS keys is modified in one of two ways:

  1. Modify the XXXX.keyr file. Build the project and then download the image file.
  2. By using “Cs_Config tool” available in the SDK

8 “users keys” is used in your application to store application specific settings in the persistent storage.

cs-keys-lm930-lm931-screenshot

Note: &CRYSTAL_FTRIM and &TX_POWER_LEVEL should not be modified by the user.

 

 

 

LM930/ LM931: Getting Started with Bluetooth Low Energy (BLE)

Introduction

lm930_lm931_phone

The LM930/ LM931 Bluetooth Low Energy (BLE) module makes it incredibly easy and cost effective to design your wireless product. The LM930/ LM931 communicates with a phone, tablet or embedded system with the LM961 over a BLE connection. Bluetooth Low Energy (BLE) is a light-weight version of the Bluetooth Classic ideal for the developer to create small applications.

The lower level protocol firmware of the Bluetooth v4.1 stack is stored in the ROM. Your unique application firmware communicates with the stack with APIs. This application firmware is programmed and debugged within the CSR μEnergy SDK provided with the LM53X development kit. Your application is then flashed over SPI to the EEPROM. GAP is used to establish Bluetooth Low Energy connections, while GATT defines how the data is organised and sent bidirectional between the LM930/ LM931 and another BLE device.

 

 

Generic Access Profile (GAP)

The Generic Access Profile is part of the CSR Bluetooth v4.1 stack used for controlling the connection between your product with the LM930/ LM931 and another BLE device.

 

LM930/ LM931 GAP Roles

In a Bluetooth Low Energy point to point connection there are two roles:

  • GAP Peripheral – The LM930/ LM931 is defined as a peripheral device as it has all the resources for a small application e.g. a monitor, meter and iBeacon.
  • GAP Central – Typically phones, tablets and computers with a more powerfully processor and larger memory capacity.

 

Advertising and Scanning

LM930/ LM931 advertises (broadcasts) its presence to all the GAP Central devices within range. It advertises with 31 byte advertising payloads which can state a predefined device name. The GAP Central device sends scan response payloads the same as the advertising payload sent by the peripheral. The advertising payloads are sent in intervals within a window of time defined by the developer in the CSR μEnergy SDK. The shorter the interval and window set in milliseconds the more responsive the advertising will be. However, there is a trade-off between the responsiveness and the battery life when using a small battery to power your application. Once the LM930/ LM931 has made a connection with a GAP Central device it will stop advertising it’s presence to other central devices. It will only transmit advertising payloads again when the connection has dropped. The BLE connection between the LM930/ LM931 and the central device allows GATT services to transfer data in both directions.

 

Wireless Personal Area Network (WPAN)

gap_peripher_devices

In a Bluetooth Low Energy network the GAP Central device can connect to up to 7 GAP Peripheral devices. Data can be sent over these 7 connection simultaneously, only restricted by the processing power and memory size of the GAP central device.

The LM930/ LM931 forms a connections with one GAP Central device at a time and can communicate with another peripheral device through the connected central device.

 

Broadcast Data

lm930_lm931_broadcasting

The LM930/ LM931 GAP Peripheral module is able to send data to more than one device as a broadcast.  The data is sent one way to any GAP Central device in range as a 31 byte advertising packet. Our iBeacon firmware is available on the LM930/ LM931 for sending the broadcast messages.

 

 

 Generic Attribute Profile (GATT)

application_profile

The CSR μEnergy SDK is used to develop GATT Services. GATT Service firmware operates on the LM930/ LM931 once GAP has established the connection. Within the firmware you can define the way the LM930/ LM931 transfer data to the connected GAP Central device and vice versa. The data is transferred in a client/ server architecture, where the LM930/ LM931 is the server and the connected GAP central device is the client. The LM930/ LM931 is responsible for responding to all the requests of the client.

In development one or more services are implemented within your application to execute the required behaviour. For example the key fob demo application consists of a Battery Service, Device Information service and a customised Automation IO service for the switches and RGB LED functionality. With the LM930/ LM931 you can use and modify existing services and create new ones. All services are stored in the Attribute (ATT) protocol lookup table using a UUID. The service contain characteristics used to define the procedures and formats of the services.

heart_rate_service

LM930/ LM931: Flashing Application on Windows Commmand Line User Guide

Overview

This user guide explains how to flash LM demo applications on the Windows command line to the EEPROM of a LM930/ LM931 (using the LM53X development kit).

 

Flashing Application Firmware to the LM930/ LM931

All demo applications provided by LM are compiled and the resulting image is ready to be flashed into the LM93X module EEPROM memory. This is interfaced with the MCU through the I2C bus.

Execute the following steps to flash the demo application image to the LM93X memory using the command line, without opening the IDE program:

1/ Download the required LM demo application zip provided e.g. LM93X_SOFT_IBEACON_V1.1. (This includes the source files (.c, .h etc.), the SDK project files and the EEPROM image (.img).

2/ Check that the demo image is present in the demo application folder, for example: LM93X_iBeacon_v1.1\eeprom_image\LM93X_iBeacon_v1.1.img

And copy the image to your development folder.

3/ Open a windows terminal and then change the directory to the uEnergy SDK folder path such as the following:

C:\CSR_uEnergy_SDK-2.4.5.13\tools\bin

4/ Run the following command:

e2cmd.exe download [demo_application_folder_path]\image_filename.img

for example:

e2cmd.exe download C:\Users\Marco\Documents\Projects\Images\LM93X_iBeacon_v1.1.img

An output displayed below should appear:

img

5/ In order to verify the download run the following command:

e2cmd.exe verify [demo_application_folder_path]\image_filename.img

for example:

e2cmd.exe verify C:\Users\Marco\Documents\Projects\Images\LM93X_iBeacon_v1.1.img

An output displayed below should appear:

img2

Note 1: step 5 is not mandatory.

Note 2: for information about the e2cmd.exe command run e2cmd.exe –help.