Arm Case-Study: The Raspberry Pi: Razvan Bogdan Microprocessor Systems
Arm Case-Study: The Raspberry Pi: Razvan Bogdan Microprocessor Systems
RASPBERRY PI
Razvan Bogdan
Microprocessor Systems
Content
Raspberry Pi Board Configurations
Architecture Overview
Interfacing the Pi
1-wire interface
Serial Interface
USB Interface
Introduction
Created by Eben Upton, Rob Mullins, Jack Lang and Alan Mycroft at
University of Cambridge
They, in conjunction with Pete Lomas and David Braben, formed the
Raspberry Pi Foundation
Was created to provide inexpensive programming machines
CPU core: ARM1176JZF-S ARM11 core clocked at 700MHz. The ARM11 core
implements the ARMv6 Architecture.
GPU core: a Broadcom VideoCore IV GPU providing OpenGL ES 1.1, OpenGL ES
2.0, hardware-accelerated OpenVG 1.1, Open EGL, OpenMAX and 1080p30
H.264 high-profile decode.
DSP core
256MiB of (Hynix MobileDDR2 or Samsung Mobile DRAM) SDRAM (or 512MB
Mobile DRAM on later boards). The RAM is physically stacked on top of the
Broadcom media processor (package-on-package technology).
Raspberry Pi Board Configurations
Raspberry Pi 1
http://hackaday.com/2016/02/28/introducing-the-raspberry-pi-3/
Raspberry Pi Board Configurations
Raspberry Pi 3
the biggest
gains go to
multi‐threaded
programs
Raspberry Pi Board Configurations
Raspberry Pi 3
Source:
https://www.raspberrypi.org/magpi/raspberry-
pi-3-specs-benchmarks/
Architecture Overview. System on Chip (SoC)
Benefits of SoC
Reduce overall system
cost
Increase performance
Lower power consumption
Reduce size
System on Chip
(SoC)
System on Chip (SoC). BCM2835
Core
Load Store Unit
Prefetch Unit
Memory System
Level One Mem.
System
Interrupt Handling
System Control
AMBA Interface
Coprocessor
Interface
Debug
Instruction cycle
summary and interlocks
Vector Floating-Point
BCM2835. GPU overview
Broadcom Videocore IV
Uses OpenGL ES2.0
Performance: 24 GFLOPS
RPi can play 1080p Blu-Ray quality
videos
Graphical capabilities are similar to
the those of the original XBOX
Applications:
Robotics
Game emulation
Media Servers
Education (Python is the primary
language used)
Powerful enough to be used as a
personal computer
System on Chip (SoC). BCM2836
The Raspberry Pi 2 main chip is the Broadcom BCM2836 System on a Chip (SoC); it is
running at 900Mhz, based on the quad-core ARM Cortex-A7
The ARM Cortex-A7 processor
is a 32-bit processor core
implementing the ARMv7-A architecture.
System on Chip (SoC). BCM2837
Note that although that the Pi is powered using 5V, all of its signaling is done
using 3.3V
This is a VERY IMPORTANT thing to watch for, NEVER connect the Pi directly
to any circuits using 5V signaling
Note that Arduino uses 5V signaling, so all Arduino circuits can not be
connected to the Pi
The Pi does not have an over voltage protection for its pins, hence you can
easily destroy the board by connecting it to 5V circuits
If you need to use chips that run with 5V logic such as those running with
Arduino boards,
If the chip only takes output from the Pi, sometimes, the 3.3V of the Pi is good
enough for the external chip to detect logic 1
If the 3.3V of the Pi is not enough to drive the chip, then you need a 3.3V to
5V Level Shifter
If the chip provides input to the Pi, then you will always need to use a 5V to
3.3V Level Shifter. Not doing that will damage your Pi Board
GPIO Header Signals. 3.3V Line
These pins can be used to provide power to 3.3V circuits (If not going to
overload the Pi)
This is NOT an input signal, the Pi only takes 5V line, this is an output line
GPIO Header Signals. Ground Line
These pins represent common signals between the Pi and external circuits
connected to it
GPIO Header Signals. GPIO Signals
These two pins are introduced in model B+ to enable a new concept called
Raspberry Pi HATs
A Pi HAT (Hardware Attached on Top), is a daughter board that can be connected
on top of the Pi
The Pi uses those two pins to read an ID EEPROM that describes the attached
hardware and the required configuration of the GPIO pins
GPIO Header Signals. ID EEPROM Signals
Interfacing to the GPIO Header
The 1-Wire protocol was developed by Dallas Semiconductor Corp. initially for
the iButton
The 1-Wire protocol actually uses two wires:
Data: The single wire used for data communication
Ground: The ground or “return” wire
The 1-Wire protocol was designed for communication with low–data content
devices like temperature sensors
It provides for low-cost remote sensing by supplying power over the same wire
used for data communications
Each sensor can accept power from the data line while the data line is in the high state
When the data line is active (going low), the sensor chips continue to run off of their
internal capacitors (in parasitic mode)
The device also provides an optional VDD pin, allowing power to be supplied to it
directly. This is sometimes used when parasitic mode doesn’t work well enough. This, of
course, requires an added wire, which adds to the cost of the circuit.
The 1-wire Interface. Line Driving
The data line is driven by open collector transistors in the master and slave devices.
The line is held high by a pull-up resistor when the driver transistors are all in the Off
state.
To initiate a signal, one transistor turns on and thus pulls the line down to ground
potential.
The 1-wire Interface. Line Driving
However, when the master device activates transistor M2, current is caused to flow
from the bus to the ground, acting like a signal short-circuit. Slave devices attached
to the bus will see a voltage near zero.
The 1-wire Interface. Master and Slave
The master device is always in control of the 1-Wire bus. Slaves speak only to
the master, and only when requested.
There is never slave-to-slave device communication.
If the master finds that communication becomes difficult for some reason, it may
force a bus reset. This corrects for an errant slave device that might be jabbering
on the line.
The 1-wire Interface. Data I/O protocol (1 of 2)
When a 1 bit is being transmitted, the line is held low for only about 6 microsec
before releasing the bus.
Another data bit is not begun until 70 microsec after the start of the previous bit.
This leaves a guard time of 10 microsec between bits. The receiver then has ample
time to process the bit and gains some signal noise immunity
The 1-wire Interface. Data I/O protocol (2 of 2)
Having registered a data bit, the receiver then waits further until the line returns
high (in the case of a 0 bit).
The receiver remains idle until it notices the line going low again, announcing the
start of the next bit.
The sender can be either the master or the slave, but the master always has control.
Slaves do not write data to the bus unless the master has specifically requested it.
The 1-wire Interface. Slave Devices
Dallas DS18B20 slave device; this temperature sensor is typical of many 1-wire
slave devices
In order to interface this with the Raspberry Pi we just need one resistor - a 4k7
which acts as a pull-up resistor
Raspbian Linux has its driver support for the 1-Wire bus on GPIO 4 (P1-07).
The 1-wire Interface. Slave Devices
Reading temperature readings from multiple sensors down one wire is possible
because each DS18b20 sensor has a unique serial number coded into it at
manufacture which the Raspberry Pi can be used to identify them by.
Serial interface
The serial interface consists of all the basic circuits and programs that
provide communication between the central unit and a peripheral
equipment, which is of bit by bit type .
Serial transfer is very useful when there are large distances (more than 3 m)
between communicating devices.
There are two reasons that support this recommendation: cost and the
resistance to interferences:
Cost is determined by the number of wires in the cable that connects the 2
devices: if this number is low, the cost will be lower;
Serial transfer has a greater resistance to interferences than parallel transfer for
two reasons :
the possibility of disrupting lines decreases if the number is lower and
the distance between two voltage levels corresponding to logic levels is higher than the
parallel transfer.
Serial interface
Often used in data communication between a DTE and a DCE with or without
a modem.
DTE stands for data terminal equipment and can be either a computer or a
terminal.
DCE stands for data communication equipment. A modem is a DCE.
Communication link
Was the most widely used physical level interface for data communication
Specifies 25 interchange circuits for DTE/DCE use
Established in 1960 by Electronics Industry Association (EIA)
Revised to RS232C in 1969
Revised to RS232D in 1987
Revised to RS232E in 1992 and renamed as EIA-232-E
Revised and renamed to TIA-232F in 1997
Serial interface
5 Ground
Ring indicator 9
4 DTE ready
Clear to send 8
3 Transmitted data
Request to send 7
2 Received data
DCE ready 6
1 Received line signal detect
The speed:
Slow;
There are two units of the speed of transfer: bit per second (bps) and baud.
A baud is defined as a power transition line.
If the transfer between the two devices, for example, two computers, takes place
in digital form, that the two devices are connected to serial lines directly without
MODEM, then 1 bps = 1 baud.
If the transfer takes place in analog form, on the telephone lines between two
modems, for example, then1baud ≠ 1 bps.
The relationship between them depends on the method of encoding data lines
used by MODEMs.
It is customary to work with certain speeds. Most common speeds used are: 300,
600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200 rarely
230400, 460800 bps.
Serial interface
Features:
Character-level synchronization by the START bit,
5-8 bits of data,
Optional parity bit
1, 1.5, 2 stop bits.
Serial interface
START false pulse rejection and reading information from the receiver:
Notation established:
8n2 is meaning asynchronous transfer with 8 data bits, no parity, and 2 stop
bits
7e1 is meaning transfer with 7 data bits , even parity and 1 STOP bit etc.
The letter e indicates parity (“even") and the letter o indicates odd parity
("odd").
Serial interface
Serial interface
Synchronous Transfer: block transfer, the transfer is made at block level or message .
The transmitter can start at any time the transmission of a block but once started, it must
submit all characters that form it.
A block starts with one to five special characters that serve as synchronization.
The receiver continuously test the line, it assembles received data and compares the
received data with synchronization characters.
From the programming phase, the receiver knows how many synchronization characters
the transmitter uses and what are these characters.
If the appearances of these characters has been detected, following next, there will be
the assembling of characters’ bits that make up the sent message.
If at the asynchronous transfer there is a synchronization at the character level, realized
through the START bit, here is a bit-level synchronization; each bit is transmitted at well-
defined time moments, determined by clock, commissioned by the transmitter.
There are techniques for combining data and clock on the same line.
Serial interface
Advantages:
Provides higher speed due to:
The existence of the clock;
Removes framing information on character level.
Disadvantages:
Synchronization characters are necessary so if the block is short, less than 8
characters, the synchronous mode is no longer effective;
Additional line tact.
Flow control: how does the transmitter find that the receiver can not retrieve
any character? - For various reasons, for example: its buffer is full, the line is
disconnected etc., it is useless to send them because, otherwise, they are lost.
There are three solutions:
Without control;
With software control ( “software handshaking” ) and
With hardware control ( “ hardware handshaking” ).
The first solution: the transmitter and the receiver working at the same low speed;
The second solution: the use of two control characters: XON with DC1 code (11h)
and XOFF with DC3 code (13h); the receiver sends XON if it wants a transfer
and XOFF if it does not want a transfer.
A third solution: makes a dialogue between the transmitter and receiver via two
signals. When the transmitter wants to transfer something, enables RTS line. If the
receiver can receive information, will respond by activating the CTS line and
when it can not get any information, it will disable the CTS line. This solution is
faster than the previous one but requires an extra 2-wire cable.
Serial interface
Errors:
Framing (“Frame Error“),
parity (“Parity Error”),
Rate (“Overrun Error”) and
stop (“Break”).
“Break”: a special situation created intentionally by the transmitter; normally, if
the line is inactive, it is logical 1; the Break condition is forced by the transmitter
which passes the line to logic 0 for a relatively long period, from 0.25 to 0.5 sec.
and it is seen by the receiver;
For all errors, the specialized circuit does not stop the transfer but it announces
them by activating ranks of its status byte or bytes; it is the duty of the software
to handle these situations, for example requiring retransmission bytes.
Standardization:
Electronic Industries Association (EIA): the standard RS232, ...
International Telegraph and Telephone Consultative Communitee (CCIT) which
changed its name to International Telecommunications Union (ITU): the standard
V24, ...
Raspberry Pi. Serial interface
To communicate with equipment using RS-232, you will need a converter module,
like MAX232CSE chip
This unit supports only the RX and TX lines
When searching for a unit, be sure that you get one that works with 3 V logic
levels.
Some units work only with TTL (+5 V) logic, which would be harmful to the Pi.
The MAX232CSE chip will support 3 V operation when its VCC supply pin is
connected to +3 V.
Raspberry Pi. Serial interface
When choosing your RS-232 converter, keep in mind that there are two types
of serial connections:
DCE: Data communications equipment (female connector)
DTE: Data terminal equipment (male connector)
Consequently, for your Pi, choose an RS-232 converter that provides a female
(DCE) connector.
Likewise, make sure that you acquire for the laptop/desktop a cable or USB
device that presents a male (DTE) connection.
Connecting DTE to DTE or DCE to DCE requires a crossover cable, and
depending on the cable, a “gender mender” as well. It is best to get things
“straight” right from the start.
Assuming that you used a DCE converter for the Pi, connect the RS-232
converter’s 3 V logic TX to the Pi’s TXD0 and the RX to the Pi’s RXD0 data
lines.
Raspberry Pi. Serial interface
excerpt of the UART section of the Raspberry Pi, the UART connections are shown
as TXD0 and RXD0.
Raspberry Pi. Serial interface
Hardware Flow Control for RPi: additional signal lines to regulate the flow of
data.
The RS-232 standards have quite an elaborate set of signals defined, but the main
signals needed for flow control on RPi are shown in table
Unlike the data line, these signals are inactive in the space state and active in the
mark state
Raspberry Pi. Serial interface
Hardware Flow Control for RPi: additional signal lines to regulate the flow of
data.
When CTS is active (mark), for example, the DCE (Pi) is indicating that it is OK to
send data. If the DCE gets overwhelmed by the volume of data, the CTS signal will
change to the inactive (space) state.
Upon seeing this, the DTE (laptop) is required to stop sending data. (Otherwise, loss
of data may occur.)
Similarly, the laptop operating as the DTE is receiving data from the DCE (Pi). If the
laptop gets overwhelmed with the volume of incoming data, the RTS signal is
changed to the inactive state (space). The remote end (DCE) is then expected to
cease transmitting.
When the laptop has caught up, it will reassert RTS, giving the DCE permission to
resume.
Raspberry Pi. Serial interface
Hardware Flow Control for RPi: additional signal lines to regulate the flow of
data.
The DTR and DSR signals are intended to convey the readiness of the equipment at
each end.
If the terminal was deemed not ready (DTR), DSR is not made active by the DCE.
Similarly, the terminal will not assert DTR unless it is ready.
In modern serial links, DTR and DSR are often assumed to be true, leaving only CTS
and RTS to handle flow control.
Where flow control is required, hardware flow control is considered more reliable
than software flow control
Raspberry Pi. Serial interface
Some websites have incorrectly stated that the mini UART is the one being used. But
this does not in accordance with the Broadcom documentation, nor the Raspbian
Linux device driver. The Broadcom BCM2835 ARM Peripherals manual states that
the mini UART is UART1. UART1 is available only as alternate function 5 for GPIO
14 and 15. Raspbian Linux boots up using alternate function 0 for GPIO 14 and
15, providing the UART0 peripheral instead.
Raspberry Pi. Serial interface
Two factors contributing most to the success of the personal digital revolution that
encompasses desktop computers, laptops and notebooks, MP3 players and both
still and digital cameras as well as cellular phones, are flash memory and the
universal serial bus, USB.
Flash memory provides robust, high-density, low size, non-volatile storage at low
prices, and USB technology allows you to connect almost any modern digital device
to a computer – or even to connect two digital devices together without a host
computer (e.g., a camera and a printer).
Indeed, the USB is the single most successful digital interface ever, with over one
billion USB devices sold by 2009.
USB Interface
USB History
In 2000 USB 2.0 emerged to provide a maximum data rate of 480 Mb/s.
USB had jumped into FireWire territory and it became the de facto standard
for most PC interfaces to printers, external drives, keyboards, mice, and so on.
It wasn’t until 2009 that version 3.0 USB saw the light of day with an
operating speed of 300 MB/s (i.e., 2,400 Mb/s) displacing FireWire from its
eight-end niche. USB 3.0 is a giant leap forward over version 2.0 and
requires a new cable format and technology.
USB Interface
A USB bus uses low cost connectors and cabling to connect a computer to
a range of peripherals from the mouse/keyboard/printer/scanner to
memory devices such as external hard-drives and flash memory devices
(so called pen drives).
USB uses a simple multicore connector with dedicated connectors. However, since the
introduction of USB, peripherals have become smaller and smaller and USB cables have
been forced to follow this trend with the result that there are now four basic sizes.
Figure 12.71 illustrates both USB plugs and sockets. The computer end of the link uses type
A sockets and type B plugs which are fairly substantial. Type B plugs and sockets are used
at the other end of the link (i.e., at a hub or a peripheral such as a printer).
Mini-B plugs and sockets were developed for digital cameras, cell phones, and portable
disk drives
USB Interface
More Power
The USB’s ability to deliver power was intended to support hubs and
peripherals like the mouse and keyboard.
A new power mode was added to the USB specification called battery
charging. A host can supply up to 1.5A when communicating at 12 Mbps, or
0.9A when communicating at 480 Mbps.
At the electrical level the USB employs NRZI data encoding where a logical 1 is
represented by no change of level and a 0 is represented by a change of level. Sending a
string of 0s requires the greatest bandwidth and transmitting a sequence of 1s results in a
constant level with no signal transitions.
Figure 12.75 illustrates a NRZI sequence, the two signal levels on a USB bus are referred to
as J and K.
USB Interface. Logical Layer
Logically, a communications channel exists between the host and device, and in USB-speak
this channel is called a pipe. The USB host can support 32 active pipes at any instant (16
up-stream and 16-down-stream pipes).
USB 3.0
The most radical change to the universal bus took place in 2010 with the
introduction of USB 3.0 which provides a tenfold increase in performance and
uses less power.
Even more remarkably, USB 3.0 is physically compatible with USB 2. USB 3.0
is interesting because it is not really a development or extension of USB 2.0,
but a replacement bus that coexists with USB 2.0; that is, a USB 3.0 bus
incorporates a USB 2.0 bus as well.
USB Interface
Figure 12.77 illustrates the structure of the USB 3.0 cable. The two data carrying
conductors of USB 2.0 are maintained as well as the two power conductors.
Two new differential pairs of conductors (SSRX and SSTX) have been added carry the new
USB 3.0 data in a full duplex bidirectional mode.
USB Interface
The additional functionality of USB 3.0 is called the SuperSpeed bus which
provides a maximum speed of 4.8 Gb/s.
To put this into context, it takes USB 2.0 13.9 minutes to transfer an HD movie,
whereas USB 3.0 can perform the transfer in only 70s.
In short, USB 3.0 is an impressive feat of engineering that take a great leap
ahead in terms of functionality and performance, while maintaining backward
compatibility with a vast existing market of USB 2.0 users.
USB Interface
Figure 12.78 illustrates the logical structure of the USB 3.0 bus in terms of protocol layers
(like the ISO 7 layer model for open systems interconnection).
The SuperSpeed bus that adds all the new functionality to USB 3.0
Data is scrambled on SuperBus. This is not a security mechanism but a means or converting
data into a sequence that appears random in order to improve the electrical properties of
the data link.
Raspberry Pi. USB Interface
The Model B
Raspberry Pi supports
two USB 2 ports, the
Model A just one,
Raspberry Pi 3 has 4
USB 2.0
Raspberry Pi. USB Interface
SERIAL
COMMUNICATION
VIA USB
Raspberry Pi. USB Interface
The signaling used by the DHT sensor is similar to the 1-Wire protocol, but the
response times differ;
there is no device serial number support. These factors make the device
incompatible with the 1-Wire drivers
The datasheet states that the DHT11 can be powered by a range of voltages,
from 3 V to 5.5 V.
Powering it from the Raspberry Pi’s 3.3 V source keeps the sensor signal levels
within a safe range for GPIO.
draws between 0.5 mA and 2.5 mA. Its standby current is stated as 100 mA to
150 mA, for those concerned about battery consumption
Raspberry Pi. DHT11 Sensor
Pin 4 connects to the common ground, while pin 1 goes to the 3.3 V supply.
Pin 2 is the signal pin, which communicates with a chosen GPIO pin (e.g. GPIO 4
or 22 etc)
When the Pi is listening on the GPIO pin and the DHT11 is not sending data, the line will
float. For this reason, R1 is required to pull the line up to a stable level of 3.3 V. The
datasheet recommends a 5 kOhm resistor for the purpose (a more common 4.7 kOhm
resistor can be substituted safely). This presents less than 1 mA of load on either the GPIO
pin or the sensor when they are active. The datasheet also states that the 5 kOhm resistor
should be suitable for cable runs of up to 20 meters.
Raspberry Pi. DHT11 Sensor
The sensor speaks only when spoken to by the master (Raspberry Pi).
The master must first make a request on the bus and then wait for the sensor to
respond.
The DHT sensor responds with 40 bits of information, 8 of which are a checksum.
The datasheet states 16 bits of relative humidity, 16 bits of temperature in Celsius, and
an 8-bit checksum. However, the DHT11 always sends 0s for the humidity and
temperature fractional bytes. Thus the device really has only 8 bits of precision for each
measurement
Raspberry Pi. DHT11 Sensor
Overall protocol:
1. The line idles high because of the pull-up resistor.
2. The master pulls the line low for at least 18 ms to signal a read request and
then releases the bus, allowing the line to return to a high state.
3. After a pause of about 20 to 40 ms, the sensor responds by bringing the line
low for 80 ms and then allows the line to return high for a further 80 ms. This
signals its intention to return data.
4. Forty bits of information are then written out to the bus: each bit starting with a
50 ms low followed by:
a. 26 to 28 ms of high to indicate a 0 bit
b. 70 ms of high to indicate a 1 bit
5. The transmission ends with the sensor bringing the line low one more time for 50
ms.
6. The sensor releases the bus, allowing the line to return to a high idle state.
Raspberry Pi. DHT11 Sensor
Overall protocol:
Master control is shown in thick lines, while sensor control is shown in thin lines.
Initially, the bus sits idle until the master brings the line low and releases it
(labeled Request).
The sensor grabs the bus and signals that it is responding (80 ms low, followed by
80 ms high).
The sensor continues with 40 bits of sensor data, ending with one more transition
to low (labeled End) to mark the end of the last bit.
Content
Raspberry Pi Board Configurations
Architecture Overview
Interfacing the Pi
1-wire interface
Serial Interface
USB Interface
DHT11 Sensor
Homework:
For a Raspberry Pi board, present the design (scheme,
explanations, algorithm – pseudocode or logic scheme) of
the following system:
Connect to the RPi one of the sensors presented in the course
Read the data from it
Send the information on the serial interface (the method you
prefer) to PC/laptop
Acknowledge the correct reception on the laptop by lighting a LED
on the Raspberry Pi
Additional resources:
Introducing the Raspberry PI 3:
http://hackaday.com/2016/02/28/introducing-the-
raspberry-pi-3/
SoC vs SIP:
http://www.eetimes.com/document.asp?doc_id=1153043