Posts

LM930/931: Connection troubleshooting

If you are experiencing connection issues, check if the UART settings are correct.

The UART settings are fixed as the following:

When using a BLE app to scan for the Serial Server application you must enable the “notification flag” to receive the data from the module.

 

LM930/931: Where to find the source code

The source code is supplied with the purchase of the LM53X development kit. The CSR uEnergy SDK is required to compile and load the source code.

A link to the LM53X product page can be found here.

For further support regarding BLE development please contact LM here.

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