Lecture Raspberry Pi

Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Raspberry Pi

• Introduction to
Raspberry Pi

1
What is a Raspberry Pi?
• A credit card sized PC
• Plugs into a TV or monitor
• Inexpensive(ish) ~$35 each
• Capability:
– Programming
– Electronic Projects
– Office
– Play HD Videos

2
Application and Uses
Robotics
● Game emulation
● Education (Python is the
primary language used)
● Powerful enough to be used as personal
computer
● Thousands of projects

3
Kit Components
• Essential:
– Raspberry Pi board
– Prepared Operating System SD Card
– USB keyboard
– Display (with HDMI)
– Power Supply
• Highly suggested extras include:
– USB mouse
– Internet connectivity - LAN cable
– Case
CPU
ARM Processor,700MHz

Low power draw

GPU
Broadcom Video
Specialized graphical instruction sets

RAM
512MB (Model B)

5
System on Chip (SoC)
What is System on Chip?
A complex IC that integrates the major functional elements
into a single chip or chipset.

programmable processor
on-chip memory
accelerating function hardware (e.g. GPU)
both hardware and software
analog components

Benefits of SoC
Reduce overall system cost
Increase performance
Lower power consumption
Reduce size

6
Programming Languages
• The Raspberry Pi Foundation recommends Python
• Any language which will compile for ARM
processor can be used.

7
Power
5v micro
USB
connector

(Similar to the one on a lot of mobile


phones!)
8
3.5mm Audio
A/V (Audio/Video) Standard
headphone
socket
RCA Video
(works with most
older TVs)

HDMI Audio & Video


(works with modern TVs and DVI monitors) 9
Connectivity
2 x USB 2.0
ports

GPIO
(General
Purpose
Input &
Output)

10/100Mb
Ethernet
10
General Purpose Input/Output
(GPIO)

Pins can be configured to be input/output

Reading from various environmental sensors

Ex: IR, video,temperature, 3-axis
orientation,acceleration

Writing output to dc motors, LEDs for status.

11
12
General Purpose Input/Output (GPIO)
General Purpose Input/Output (GPIO) is a generic pin on a chip
whose behavior can be controlled by the user at run time.

The GPIO connector has a number of different types of connection:



True GPIO (General Purpose Input Output) pins that you can use to
turn LEDs on and off etc.

I2C interface pins that allow you to connect hardware modules with just
two control pins

SPI interface with SPI devices, a similar concept to I2C but uses a
different standard

Serial Rx and Tx pins for communication with serial peripherals

Broadcom SOC channel(BCM)


13
General Purpose Input/Output (GPIO)
GPIO pins can be used as both digital outputs and
digital inputs.

Output: turn a particular pin HIGH or LOW.

Setting it HIGH sets it to 3.3V; setting it LOW sets it to


0V.

Input: detect the pin being at HIGH or LOW

we can connect switches and simple sensors to a pin


and check whether it is open or closed (that is activated
or not)

14
General Purpose Input/Output (GPIO)

Broadcom SOC channel

All the pins have 3.3V logic levels and are not 5V-safe so the output
levels are 0-3.3V and the inputs should not be higher than 3.3V.
15
Internals LAN Controller

DSI
(display
interface) CSI
(camera
interface)
SOC (System On a Chip)
Broadcom BCM2835 700Mhz
16
Storage

SD Card Slot
(supports SD cards up to 32GB) 17
Models A and B Specification
Two Models A & B, priced at $25 and $35
respectively
● Model A/B:
○ Broadcom BCM2835 (CPU & GPU(Graphics
Processing Unit)
○ 256/512MB RAM
○ 1/2 USB 2.0 Ports
○ None/Ethernet Port
○ HDMI
○ Audio
○ SD Card Slot
○ Micro USB for power

18
Blinking of LED
import RPi.GPIO as GPIO import RPi.GPIO as GPIO
import time import time
GPIO.setmode(GPIO.BCM)
GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.OUT)
GPIO.setup(8, GPIO.OUT) while (True):
while (True): GPIO.output(18,True)
GPIO.output(8,True)
time.sleep(1)
time.sleep(1)
GPIO.output(8,False) GPIO.output(18,False)
time.sleep(1) time.sleep(1)
GPIO.cleanup()

19
Interfacing of Switch and LED
import RPi.GPIO as IO
import os
import time
from time import sleep
IO.setwarnings(False)
IO.setmode(IO.BOARD)
IO.cleanup()
switch=5
led=8
IO.setup(switch,IO.IN)
IO.setup(led,IO.OUT)
while True:
print(IO.input(sensor))
if(IO.input(sensor)==1):
IO.output(led,True)
print('done1')
else:
IO.output(led,False)
print('done2')
20
ARM Processor
ARM is a 32-bit load / store architecture
The only memory accesses allowed are loads and stores
Most internal registers are 32 bits wide
Most instructions execute in a single cycle

When used in relation to ARM cores


Halfword means 16 bits (two bytes)
Word means 32 bits (four bytes)
Doubleword means 64 bits (eight bytes)

21
Processor Modes
• ARM has seven basic operating modes
– Each mode has access to its own stack space and a different subset of
registers
– Some operations can only be carried out in a privileged mode
Mode Description
Supervisor Entered on reset and when a Supervisor call
Exception modes

(SVC) instruction (SVC) is executed


Entered when a high priority (fast) interrupt is
FIQ
raised

IRQ Entered when a normal priority interrupt is raised


Privileged
modes
Abort Used to handle memory access violations

Undef Used to handle undefined instructions

Privileged mode using the same registers as User


System
mode
Mode under which most Applications / OS tasks Unprivileged
User
run mode
The ARM Register Set
User mode IRQ FIQ Undef Abort SVC
r0
r1
r2 ARM has 37 registers, all 32-bits long
r3
r4 A subset of these registers is accessible in
r5 each mode
r6 Note: System mode uses the User mode
r7 register set.
r8 r8
r9 r9
r10 r10
r11 r11
r12 r12
r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp) r13 (sp)
r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr) r14 (lr)
r15 (pc)

cpsr
spsr spsr spsr spsr spsr

Current mode Banked out registers


Program Status Registers
31 28 27 24 23 19 16 15 10 9 8 7 6 5 4 0

N Z C V Q [de] J GE[3:0] IT[abc] E A I F T mode


f s x c
• Condition code flags • T bit
– N = Negative result from ALU – T = 0: Processor in ARM state
– Z = Zero result from ALU – T = 1: Processor in Thumb state
– C = ALU operation Carried out • J bit
– V = ALU operation oVerflowed – J = 1: Processor in Jazelle state
• Mode bits
• Sticky Overflow flag - Q flag – Specify the processor mode
– Indicates if saturation has occurred • Interrupt Disable bits
– I = 1: Disables IRQ
• SIMD Condition code bits – GE[3:0] – F = 1: Disables FIQ
– Used by some SIMD instructions • E bit
– E = 0: Data load/store is little endian
• IF THEN status bits – IT[abcde] – E = 1: Data load/store is bigendian
– Controls conditional execution of Thumb • A bit
instructions – A = 1: Disable imprecise data aborts
ARM Processor links
https://static.docs.arm.com/ddi0419/d/DDI0419D_armv6m_arm.pdf

https://www.arm.com/.../ppt/ARM_Processors_and_Architectures_Uni_Program_.p

25
Some useful links
Raspberry Pi official website

http://www.raspberrypi.org/

Raspberry Pi wiki

http://elinux.org/RaspberryPiBoard

Raspberry Pi verified peripherals

http://elinux.org/RPi_VerifiedPeripherals

The MagPi

http://www.themagpi.com

Raspberry Pi on Adafruit Learning System:

http://learn.adafruit.com/category/learn-raspberry-pi
26

You might also like