Bosch XDK110 Getting Started

XDK110: Getting Started Guide with Extension Bus
Cross-Domain Development Kit XDK110
Platform for Application Development
XDK110: Extension Bus Advanced Guide
Document revision
Document release date
Workbench version
Document number
Technical reference code(s)
Notes
| 2 24
Extension Bus Advanced Guide | XDK110
XDK110
Platform for Application Development
Table of contents
1. General Description 4
1.1 General Introduction 4.............................................................................................................................................
1.2 Connecting the Extension Bus 4.............................................................................................................................
1.3 MCU pins on the Extension Bus 4...........................................................................................................................
2. Extension Bus Advanced API Overview 6
2.1 Preparation 6...........................................................................................................................................................
3. UART (Universal Asynchronous Receiver-Transmitter) 7
3.1 General Introduction 7.............................................................................................................................................
Configurable parameters for UART are: 7.....................................................................................................................
3.2 Initializing and configuring UART 8.........................................................................................................................
3.3 Transmitting data over UART 13.............................................................................................................................
3.4 Receiving data over UART 14.................................................................................................................................
4. SPI (serial peripheral interface bus) 15
4.1 General Introduction 15...........................................................................................................................................
4.2 Initializing and configuring SPI 15...........................................................................................................................
4.3 Transmitting data over SPI 20.................................................................................................................................
4.4 Receiving data over SPI 22.....................................................................................................................................
| 3 24
Extension Bus Advanced Guide | XDK110
This guide postulates a basic understanding of the XDK and the according workspace. For new users we recommend going through the following guides at xdk.io/guides first:
-
Workbench Installation
-
Workbench First Steps
-
XDK Guide FreeRTOS!
| 4 24
Extension Bus Advanced Guide | XDK110

1. General Description

1.1 General Introduction

The XDK comes with the ability to attach a 26 pin XDK gateway called extension bus to its own 26 pin connector. The extension bus allows over the 26 additional pins access to pin functionality of the XDKs MCU pins by attaching external devices such as sensors or actuators to it. All MCU pins are GPIOs and can be configured freely within the limitations of the MCU. This way, developers can use the hardware and software of XDK to test new components with minimal application effort.
The availability and the names of the different MCU pins will be explained in section 1.3. For further information on the MCU pin functionality, please refer to the MCU data sheet(LINK).
Other than the basic Extension Bus guide, the Extension Bus Advanced guide will focus on the three most common serial bus protocols UART, SPI and I2C, all of which are mature, industry standard technologies.

1.2 Connecting the Extension Bus

Connect the 26-pin cable (included in delivery) to the extension bus board and to the 26-pin connector of the XDK. The extension bus offers a simple way to implement additional functions with external components. It is optimized for the use with breadboards.

1.3 MCU pins on the Extension Bus

The extension bus I/O pins are labeled with the respective MCU pin designator. The following table is an excerpt of the available pins on the extension bus. It only contains the pins used for the serial bus protocols used in this guide. For the complete table please refer to the basic Extension Bus guide.
Table 1. Pin labelling and configuration of the extension bus
Please note that the pins B9 and B10 are internally modified to suit the standards set for I2C pins. These pins are equipped with an internal pull-up resistor of 3.32 kOhm and are therefore usable for I2C communication only."
CONNECTOR
PIN
MCU
PIN
SUGGESTED USE
MULTIPLEX
LOCATION
MACRO
B1
PB9
UART1 TX
UART1 #2
EXTENSION_UART1_TX
B2
PB10
UART1 RX
UART1 #2
EXTENSION_UART1_RX
B3
PB2
UART1 RTS
n/a
EXTENSION_UART1_RTS
B4
PF6
UART1 CTS
n/a
EXTENSION_UART1_CTS
B5
PB4
SPI MISO
USART2 #1
EXTENSION_US2_MISO
B6
PB3
SPI MOSI
USART2 #1
EXTENSION_US2_MOSI
B7
PB5
SPI Clock
USART2 #1
EXTENSION_US2_SCK
B8
PD8
SPI Chip select
n/a
EXTENSION_US2_CS
B9
PB11
I2C1 data line ! (pull-up)
I2C1 #1
EXTENSION_I2C1_SDA
B10
PB12
I2C1 clock line! (pull-up)
I2C1 #1
EXTENSION_I2C1_SCL
B13
GND
Power
n/a
| 5 24
Extension Bus Advanced Guide | XDK110
Additionally, please note that the pins of the extension bus are protected against electrostatic discharge (ESD) up to 4 kV. This includes a serial resistance of 40 Ohm into the signal path. Please note that this is no problem for communication, but it need to be considered when powering external components via GPIO, e.g. an LED.
Keep those limitations of the Extension Bus gateway in mind when interacting with the UART, SPI and I2C pins. For further information about the general characteristics and limitations, please refer to the basic Extension Bus guide.
Before you start to connect external components to the XDK, please note the following limitations.
The pin voltage of every general purpose extension bus pin is 2.5 V. If you connect external components that work on a different voltage level, a level shifter has to be used to ensure communication with the MCU.
Failing to do so can lead to permanent damage of the XDK!
The micro controller supports four general purpose pin current drive strength settings: 0.5, 2,6 and 20 mA. The default drive strength is set to 6 mA and an alternative level can be defined for each port. For how to configure these current drive strengths, please refer to chapter 1.X in the Extension Bus Basis guide. While each pin can receive or provide maximum 20 mA current, there is a limit on the maximum combined current sourced or sank by all GPIOs. As the XDK board itself has many useful peripherals connected to the MCU, which may require specific alternative drive strength settings if enabled, it is recommended to use the default 6 mA drive strength for all I/O pins of the extension board connector and to limit the total amount of current sourced or sank through the extension board bus to 50 mA. Exceeding
these limits might permanently damage the micro controller!"
| 6 24
Extension Bus Advanced Guide | XDK110

2. Extension Bus Advanced API Overview

It is generally recommended to develop an application based on the highest API level the XDK framework supports, although it is possible to access deeper API levels if the highest level does not provide the functionality required for a specific purpose.
As with most XDK functionalities, there is an API allowing simple access to necessary functions for developing applications that use the serial bus protocols on the Extension Bus. For that the BSP and Utils API provided by the Platform layer will be used.
Picture 1 illustrates the interfaces for UART, SPI and I2C from the corresponding API.
Picture 1. API Overview

2.1 Preparation

The application in this guide is based on an empty XdkApplicationTemplate project, which can be opened from the Welcome-screen of the XDK-Workbench. The code snippets should be placed into appInitSystem() one after another. It is recommended to create a new project for every chapter (UART, SPI, I2C), based on an empty XdkApplicationTemplate.
UARTTransceiver
freeRTOS
XDK Application
EmLib
XDK Extension Bus API
SPI
UART
ExtensionPort
| 7 24
Extension Bus Advanced Guide | XDK110

3. UART (Universal Asynchronous Receiver-Transmitter)

3.1 General Introduction

UART stands short for Universal Asynchronous Receiver Transmitter and it is a physical circuit in a micro controller or a stand-alone IC. A UART’s main purpose is to transmit and receive serial data over two wires. In UART communication, two#UARTs communicate directly with each other.
UARTs transmit data asynchronously, which# means there is no clock signal to synchronize the output of bits from the transmitting UART to the sampling# of bits by the receiving UART. Instead of a clock signal, the transmitting UART adds start and stop bits to the data packet being transferred. These bits define the beginning and end of the data packet so the receiving UART knows when to start reading the bits.
Data transmitted via UART is organized into packets. Each#packet contains#1 start bit, 5 to 9 data bits (depending on the UART hardware interface), an optional parity bit, and#1 or 2 stop bits:
Picture 2. UART Packet Frame
The data rate for UART range from 230.4kbps to 16Mbps.
Configurable parameters for UART are:
Baud rate: The Baud rate is a measure of the speed of data transfer at which data can be transferred and incoming data
is read. It is expressed in bits per second (bps).
Start Bit: The first bit of an ongoing UART data packet transmission. It indicates that the data line is leaving its idle state,
typically from logic high to logic low. It simplifies communication between transmitter and receiver, but does not deliver meaningful data.
Stop Bit: The last bit of an ongoing UART data packet transmission represents the end of the data transmission. It
raises the logic level back into the idle state, typically to logic high.$
Parity bit: Parity describes the evenness or oddness of a number. The parity bit is a way for#the receiving UART to tell if
any data has#changed during transmission. After the receiving UART reads the data frame, it counts the number of bits with a value of 1 and checks if the total#is an even or odd number.#If the parity bit is a 0 (even parity), the bits in the data frame should total to an even number. If the parity bit is a 1 (odd parity), the 1 bits in the data frame should total to an odd number. When# the parity bit matches the data, the UART knows that the transmission was free of error. But if the parity bit is a 0, and the total is odd or the parity bit is a 1, and the total is even, the UART knows that bits in the data frame have changed.
Please note that for a working UART communication it is necessary that both UART endpoints operate at the same baud rate. Furthermore, the same configuration about the start, stop and parity bits need to be applied to both endpoints.
UART Packet
1 start bit
5 to 9 data bits
0 to 1 parity bits
1 to 2 stop bits
Data Frame
| 8 24
Extension Bus Advanced Guide | XDK110
3.2 Initializing and configuring UART
This section describes how to initialize UART either to receive or transmit data. It also covers the necessary configuration for the baud rate, the start bit, stop bit and parity bit. For that, the following interfaces will be used.
Code 1. Including the required UART interfaces
The BSP_ExtensionPort.h is used to connect and configure the UART interface on the Extension Bus. With it, the configuration of the Baud rate, the start, stop and parity bits will be implemented.
The following Table shows an excerpt of the functions used to implement a working UART connection.
Table 2. Function overview BSP_ExtensionPort.h
The interface BCDS_MCU_UART.h is used to initialize UART on the driver level to handle the events when data is received or transmitted via UART over the function MCU_UART_Initialize().
Furthermore, the interface BCDS_UARTTransceiver.h is used to extend UART to add functionality such as a ring buffer to store the incoming data and to send out data streams greater than one UART data packet. "
#include "BSP_ExtensionPort.h" #include "BCDS_MCU_UART.h" #include "BCDS_UARTTransceiver.h "
FUNCTION
DESCRIPTION
BSP_ExtensionPort_Connect()
This function is called to enable the power control for the extension bus and disables all GPIO pins to conserve power
BSP_ExtensionPort_ConnectUart()
This function is called to configure the corresponding UART receive (RX) and transmit (TX) pins on the extension bus
BSP_ExtensionPort_SetUartConfig()
This function is called to configure UART settings, such as Baud rate, start bit, stop bit and parity bit
BSP_ExtensionPort_GetUartHandle()
This function returns the handle for the UART communication holding all relevant configuration data
BSP_ExtensionPort_EnableUart()
This function is called to enable the UART module for transmitting and reading data
Loading...
+ 16 hidden pages