This document discusses the development of code templates to simplify serial communication between microcontrollers and sensors using various protocols. It created templates for the SPI, I2C, and UART protocols to interface a Freescale KL25Z microcontroller with sensors like an accelerometer and temperature sensor. The templates reduced the design time needed to incorporate these serial communication protocols into projects. The document tests the templates by using an accelerometer's I2C interface and displaying the output over UART in under 30 minutes, demonstrating the effectiveness of the templates for simplifying future projects.
HIGH PERFORMANCE ETHERNET PACKET PROCESSOR CORE FOR NEXT GENERATION NETWORKS
Serial Communication Protocols Simplified
1. Abstract
More and more devices are being made smart by incorporating an
embedded system: a small computing platform that is programmed to
know what the device should do without user input. For the embedded
system to function, it needs to monitor one or more sensors. The sensor
and embedded system talk through a communication protocol. For each
new protocol, a significant amount of designing time is needed to make a
sensor and an embedded system talk because designers have to go through
datasheets and perform tests of different conditions. The purpose of the
project is to set-up a template or an example code that is used to interface
to devices using the communication protocols: SPI, I2C and UART to
reduce designing process time for future applications.
Serial communication is common method of transmitting data between a
computer(master) and a peripheral device(slave) such as a programmable
instrument or even another computer. Serial communication transmits data
one bit at a time, sequentially, over a single communication line to a
receiver. Serial is also a most popular communication protocol that is used
by many devices for instrumentation.
The project “Serial Bus Communication” focuses on an embedded system
called the Freescale FRDM-KL25Z.
Fig 1: Freescale Freedom Board, TMP102, MMA8451Q
The software complier used to compose the template is the KEIL uVision5.
The temperature sensor, TMP102 and the on-board accelerometer,
MMA8451Q were used as slave devices to prototype the I2C code
template.
Another Freedom Scale board was programmed as a slave and used to
prototype the SPI code template.
The chip MA3238C was used to prototype the UART code template.
Eronmonsele M. Omiyi, Roy Melton
A/D Conversion, PWM, and Servos:
An HCS12 Assembly Language Programming Exercise
Department of Computer Engineering, Rochester Institute of Technology, Rochester, NY 14623
Universal Asynchronous
Transmitter/Receiver
(UART)
The Universal Asynchronous Receiver/Transmitter (UART) controller is
the key component of the serial communications subsystem of a computer.
The UART takes bytes of data and transmits the individual bits in a
sequential fashion. At the destination, a second UART re-assembles the
bits into complete bytes. This serial transmission is used with a terminal
through the “PuTTY” software.
The template code was created as a project file called “Tem.” This code
allows the user to output data on the terminal.
Inter-Integrated Circuit
(IIC/I2C)
Acknowledgements
Thanks to Rochester Institute of Technology Honor’s program for its
continued support towards the intellectual development of its student; The
Freescale Semiconductor for its continued support of the RIT Computer
Engineering Program and Dr. Roy W. Melton for his mentorship.
Effectiveness of The
Templates
Serial Peripheral Interface
(SPI)
Serial to Peripheral Interface (SPI) is a hardware communications protocol
developed. The Serial Peripheral Interface or SPI-bus is a simple 4-wire
serial communications interface used by many microcontroller peripheral
chips that enables the controllers and peripheral devices to communicate
with each other. A connection of two processors via SPI is just as also
possible.
The SPI bus, which operates at full duplex (means, signals carrying data
can go in both directions simultaneously), is a synchronous type data link
setup with a Master / Slave interface and can support up to 1 mega-baud or
10Mbps of speed. Both single-master and multi-master protocols are
possible in SPI. But the multi-master bus is rarely used and look awkward,
and are usually limited to a single slave.
The I²C (Inter-Integrated Circuit) is a two-wire multi-master, multi-
slave, single-ended, serial computer bus which can transmit data at a speed
of about 3.4Mbit/sec.
The template code was created as a project file called “I2C1.” This project
combines the “Tem” project and allows the user to read the registers on the
slave and display the output on the terminal.
Serial Communication with the FRDM KL25Z
Controller
Overview
To illustrate the effectiveness of this project the on-board accelerometer
(MMA8451Q) was programmed for a particular function.
The MMA8451Q used the I2C communication protocol so the template
code for I2C was simply imported into the project and took care of the
master-slave communication procedure. Because the MMA8451Q was on-
board it was difficult to probe it with an oscilloscope, the UART template
code was used to Debug and output the desired result to the terminal. The
total design time for this project was less than one-half an hour including
the time used to program the accelerometer for the desired function. Hence
in a more complex design the programmer does not need to rewrite the
protocols and even though the programmer chooses to rewrite, this
templates serve as an example with which the programmer can work with.
Fig 2: UART port, Master-Slave Connection, Template Code, Terminal Output
Fig 3:
TMP102,
UART,
Master-Multi
Slave
Connection,
Template Code,
Terminal Output
Fig 4:
UART,
Master-Multi
Slave
Connection,
Template Code,
Terminal Output