Embedded System

An embedded system is an electronic device that is designed with a very specific purpose in mind.  An embedded system consists of a microprocessor that is interconnected with other discrete components.  Each of the components is selected based on a functional requirement of the system.

Often smaller embedded systems are use to control the behavior or a specific aspect of a much larger and complex system.  An example of an embedded system would be the GPS unit in your car.  Its main purpose is to provide driving directions to the user.   The GPS is embedded within the car, along with other embedded systems: anti-lock breaks, temperature control, and engine controls just to name a few.

Embedded systems serve a different role than a general purpose computer.   Software can be written to modify the behavior of the PC in any way that you want.  If you don’t like Windows, you can always install Linux.   An embedded system is  fundamentally different.  The end user is not allowed to alter how the device functions.  You may be allowed to provide some type of input to the system, but the resulting behavior is determined by software provided by the device manufacturer, allowing little modification by the end user.

Microprocessor Overview

The microprocessor is the part of the embedded system that we will focus on in this class.  A reasonable question to ask is “Which microprocessor should we use?”  The answer is not always simple.  There are thousands of different microprocessors to choose from.   Most of the time the design requirements for a device will dictate which processor you will use.

We are going to use a type of microprocessor called a microcontroller, or MCU.   Microcontrollers come in 4, 8, 16, and 32 bit architectures.  In general, the more bits in the microcontroller architecture, the more computationally powerful it is.  Why is that the case?  Take adding two 32- bit numbers together as an example.  In an 8-bit architecture, this would require 4 separate add instructions to compute a 32-bit addition.  In a 32-bit architecture, this would only require a single instruction.  The benefit of the 8-bit architecture Vs. a 32-bit architecture is that the 8-bit MCU will most likely consume less power and be cheaper.  This leads to decision of  performance vs. power consumption

Most MCUs are considered to be a System On a  Chip or SOC.  SOCs help to simplify the design process since most of the functional blocks required for an embedded system are integrated into the processor itself.    There are often only a handful of external components (capacitors, resistors,  programming header, etc…) that are needed for an MCU to function correctly.  The low number of external parts helps reduce BOM (Bill of Materials) costs and reduce the overall price of the end product.

Microcontrollers  have a collection of interfaces that can be used interact with with other integrated circuits or peripheral devices.  The peripheral devices are specialized components that add some type of functionality to the system.  An example would be an accelerometer or a Bluetooth module.  The MCU communicates with peripheral devices using internal interfaces that are accessible by the MCU core.  These interfaces  include general purpose input/output pins (GPIO) and serial data interfaces such as UART, SPI, I2C, CAN, etc.  An MCU may also have internal peripherals such as an analog to digital converter (ADC) or a digital to analog converter (DAC).

Many embedded systems are powered using batteries.  Since long battery life is normally a desired characteristic, embedded engineers spend a great deal of time choosing a microprocessor that consumes as little energy as possible.    A significant amount of time is also spent architecting software that takes advantage of  low power modes to minimize the power consumption.  If designed correctly, its possible for a MCU based embedded system to run off of a single coin cell battery for several years without recharging the battery.

One final aspect that plays into the prevalence of microcontrollers are their low cost.  There are many, many very capable microcontrollers that can be bought for under $2.00.

The main reason we’re going to use a microcontroller is very little software is required to make an MCU do something useful.  High end CPUs require an operating system, a file system, graphics libraries, and a bunch of other software. A microcontroller on the other hand can do something useful with under 100 lines of code.

ARM Overview

We will use a ARM based MCU produced by Texas Instruments.  So  why ARM?  The simple answer is that ARM is the most prevalent microcontroller used in embedded systems development.  The ARM architecture is also easy to understand, making it a good candidate for educational purposes.

ARM stands for Advanced RISC Machine.  ARM Holdings develops processor cores and licenses the cores to partner companies that actually manufacture the processors. Partner companies take the ARM core and add a custom set of peripherals and interfaces.  Different companies customize their MCUs for different purposes.  Some focus on low power while others might focus on something like motor control.   ARM has roughly 1000 partners that develop their end products with ARM CPU cores.  In total, ARM has sold more than 30 billion processors.  ARM based processors are found in almost every cell phone and tablet currently being produced.

ARM Cortex-M Architecture

The ARM Cortex-M architecture generally consists of 3 lines of MCUs.  The Cortex-M0, Cortex-M3, and Cortex-M4 cores.  The M0 cores is designed for very low power consumption.  The M3 is designed for applications requiring additional computational power that cannot be achieved by the M0 core.  The M4 core is very similar to the M3 except that it had a dedicated floating point unit that helps with calculations commonly used with digital signal processing.

Cortex-M cores have the features listed below

All Cortex-M cores have 16 registers in the programming interface.  All of the data that is examined/modified is first loaded into a general purpose register.  After data is loaded into a general  purpose register, it can be modified/examined by the arithmetic and logic unit (ALU).  The output of the ALU is always written to one of the general purpose registers.  If data in a register needs to be saved, it is stored to SRAM.  This follows with the fact that the Cortex-M architecture is a Load/Store architecture.  We will examine how to use the general purpose registers in conjunction with ARM assembly code in the weeks to come.

MSP432 Launchpad

We will use the MSP432 Launchpad by Texas Instruments.  It is a  Cortex-M4 ARM core that contains a floating point unit and is capable of clock speeds of 48MHz.   It has 256K of program storage (FLASH) and 64KBs of dynamic memory SRAM.  It also has a very robust  set of peripheral interfaces that will allow us to interact with other external devices.

The applications we write will be compiled and assembled into ARM assembly  using TI’s Code Composer Studio integrated development environment (IDE).  Once the executable image is generated, it is loaded into the non-volatile memory (FLASH) on the MSP432P401R.  The MSP432 launchpad has an on-board in-circuit debug interface that programs the FLASH using a standard programming interface called JTAG.  In addition to programming the MCU, the on-board programmer will allow us to debug our applications in real time.