10 phillip stanley-marbell
Flash. You should think of the values which you write to memory-mapped
registers as commands: The values are not stored at that address, but rather
are taken by the hardware peripheral to which that register corresponds, to
indicate a command.
The region of memory that comprises a program, stored in Flash, has a
specific layout comprising the executable program code, data for program
constants, and so on. The layout of this region is determined by the linker,
which we will discuss further in Topic
4.
You can, in principle, write a single C program, together with some as-
sembly language code for processor initialization
8
that implements all the
8
For most target architec-
tures, you will at the very
least need a few lines of
assembly code to initial-
ize the processor’s stack
pointer.
software for your embedded system without the need for any libraries or for
an operating system. We will see one such example in Topic
4. In practice
however, it is often useful to use a software development kit (SDK). An SDK may
contain a full operating system, but typically also contains several helper rou-
tines that you can use to ease interaction with a microcontroller’s peripherals
even if you do not require an operating system. For example, the are specific
sequences of reads and writes from memory-mapped registers that you must
perform to toggle a microcontroller’s general-purpose I/O (GPIO) pins, or to
read data from one of its communication interfaces from a sensor. We will
use the Kinetis SDK (KSDK) from Freescale to provide useful helper routines.
1.3.4 Using the FRDM-KL03 and FRDM-KL05: Sensors
Sensors are fundamental to embedded systems: There is no reason to em-
bed computation in a device or environment if it could be elsewhere. The
reason for placing computation at a specific location is either to process data
from sensors, to control actuators, or both. S ensors measure a physical phe-
nomenon (e.g., temperature or linear acceleration) and transduce that sensed
phenomenon into a signal that can be digitized, such as a voltage. Some sen-
sors output these voltages directly, in which case a system design must use
an analog to digital converter (ADC) to digitize its value. Other sensors have
integrated ADCs, in which case the sensor can make sensed values available
to a microcontroller already digitized. Most often, sensors which output dig-
ital data use the SPI or I2C communication interfaces
9
. In the FRDM-KL03
9
SPI and I2C define both
an electrical interface (e.g.,
a fixed number of wires
and their roles, whether
the buffers driving pins are
open-drain or push-pull) as
well as a logical or protocol
interface (what sequences
of voltages or bit values
to use to achieve a given
communication operation).
and FRDM-KL05 development platforms, the microcontroller is connected to
a MMA8451Q 3-axis accelerometer over an I2C interface. The warmup ex-
ample provided as part of Coursework item #2 implements the software to
communicate with the accelerometer, building on routines in the Freescale
KSDK. We will discuss sensors and measurement uncertainty in Topic
2 and
will discuss I/O interfaces such as SPI and I2C in Topic
9.