Iot&a Unit-2
Iot&a Unit-2
Elements of IoT
Elements of IoT:
• Hardware Components-Arduino
• Raspberry Pi
• ARM Cortex-A class processor
• Embedded Devices – ARM Cortex-M class processor
• Arm Cortex-M0 Processor Architecture, Block Diagram
• Cortex-M0 Processor Instruction Set
• ARM and Thumb Instruction Set
Arduino
Introduction of Arduino
Example: Arduino boards are able to read inputs like light on a sensor, a finger on a button,
or a Twitter message - and turn it into an output such as activating a motor, turning on an
LED, publishing something online.
Features of Arduino:
Both hardware and software platforms are easy to use and implement.
Arduino does not need an extra board or piece to load new code.
The Arduino IDE is used to control the functions of boards. It further sends the set
of specifications to the microcontroller.
o The function of this port is to programme the board or to upload the programme.
o The one end of USB cable is connected to the laptop and another to this port.
o With help of Arduino software and USB cable, one can upload the programme on the
board.
Voltage Regulator: Regulates and stabilizes the input and output voltages.
Part-2
RX and TX LEDs: Receive (RX) and Transmit (TX) LEDs, blink when sending or receiving
serial data respectively.
Digital I/O pins: Arduino Uno Consist of 14 Digital Pins Where Output Components like:
LED, LCD, Relay etc., are connected.
AREF(Analog Reference) pins: can be used to set an external reference voltage as the upper
limit for the analog pins
Part-3
ICSP pin (In-Circuit Serial Programming): These pins are used to code and boot an Arduino
from an external source.
• Atmega328 is the microcontroller, used in basic Arduino boards i.e Arduino UNO,
Arduino Pro Mini and Arduino Nano
• It also has 3 built-in Timers, two of them are 8 Bit timers while the third one is 16-Bit
Timer.
Part-4
Reset button: This is used to start the programme again which is once uploaded.
GND pin: can be used to ground the circuit (having 3 GND pins)
Analog pins(A0-A5): Arduino Uno Consist of 6 Analog Pins, these Pins are usually used to
connect sensor like: IR Sensor, RF Sensor these all sensor have analog value that’s why they
are connected to analog pins, most of the input components are connected here.
Advantages of Arduino:
Arduino has been used for a long time in electronic projects and it has been the
favourite board of beginners in the electronic world.
Arduino is super easy to learn. Any beginner can learn Arduino with little or no
knowledge of programming.
Arduino boards are available at low cost. To start building our first program, we just
need an Arduino board as its development tool IDE is freely available.
Many Arduino libraries are available to control external sensors, modules, and
motors.
Disadvantages of Arduino:
One of the main features which Arduino lacks is it has limited memory storage.
Applications of Arduino
• Robotics
• Home Automation
• Education
• Gaming Controllers
Raspberry Pi
Feature of Raspberry Pi:
Raspberry Pi is popularly used for real time Image/Video Processing, IoT based
applications and Robotics applications.
It has been ready for public usage since 2012 with the idea of making a low-cost
educational microcomputer for students and children.
The raspberry pi comes in two models, model A and model B. The main difference
between model A and model B is USB port.
Model A board will consume less power and that does not include an Ethernet port.
But, the model B board includes an Ethernet port and designed in China.
Block Diagram of Raspberry Pi
Display: Display Serial Interface (DSI) is used for connecting LCD to Raspberry Pi using 15-
pin ribbon cables. DSI provides a high-resolution display interface that is specifically used
for sending video data.
Ethernet: The ethernet connector allows access to the wired network, it is available only
on the model B of Raspberry Pi.
USB ports: This is a common port available for various peripherals such as a mouse,
keyboard, or any other I/P device. With the help of a USB port, the system can be
expanded by connecting more peripherals.
Power supply: A micro-USB power connector is available onto which a 5V power supply
can be connected.
GPIO ports: General Purpose Input Output ports are available on Raspberry Pi which
allows the user to interface various I/P devices.
SD card: The SD card slot is available on Raspberry Pi. An SD card with an operating
system installed is required for booting the device.
Camera module: Camera Serial Interface (CSI) connects the Broadcom processor to the
Pi camera.
Different model Raspberry pi s
o Pi 1 Model B (2012)
o Pi 1 Model A (2013)
o Pi 1 Model B+ (2014)
o Pi 1 Model A+ (2014)
o Pi 2 Model B (2015)
o Pi Zero (2015)
o Pi 3 Model B (2016)
o Pi Zero W (2017)
Control unit of the Arduino is from the The control unit of Raspberry Pi is
1. ATMEGA family. from the ARM family.
It does not have internet support. It has inbuilt Ethernet port and
10. Wi-Fi support.
It has higher current drive strength. It has lower current drive strength.
11.
It is one of the extensive and most licensed processor cores in the world.
The first ARM processor was developed in the year 1978 by Cambridge
University, and the first ARM RISC processor was produced by the Acorn Group of
Computers in the year 1985.
These processors are specifically used in portable devices like digital cameras,
mobile phones, home networking modules and wireless communication
technologies and other embedded systems due to the benefits, such as low power
consumption, reasonable performance, etc.
The Cortex-R stands for the Real-time application which is used in the safety-
critical applications and where we need real-time responses of the system such as
Automotive, medical, defense, avionics and server-side technologies where data
related operations are executed.
The Cortex-M stands for the Microcontroller which is used in most of our daily life
applications also starting from the automation to DSP applications, sensors, smart
displays, IoT applications and many more. The cortex-M series is an ocean of
possibilities with a large number of probabilities and configurations.
The ARM cortex is a complicated microcontroller within the ARM family that has ARMv7
design.
Cortex-A stands for Application processor cores which are widely used in
performance-intensive applications.
They are used in a large variety of smart phones, notebooks, tablets, eBook readers,
smart television sets, and digital set top boxes for digital televisions.
ETM - Embedded Trace Macrocell (The ETM is an optional debug component that enables
reconstruction of program execution)
A NVIC is used to manage the interrupts from multiple interrupt sources. NVIC is
closely integrated with the processor core to achieve low-latency interrupt processing
and efficient processing of late-arriving interrupts.
When an interrupt request is detected, the WIC informs the power management to
power up the system so that the NVIC and the processor core can then handle the rest
of the interrupt processing.
The debug access port contains various functional blocks to handle debug control,
program breakpoints, and data watchpoints.
When a debug event occurs, it can put the processor core in a halted state so that
embedded developers can examine the status of the processor at that point.
A flash patch in an Arm Cortex-M processor, specifically utilizing the Flash Patch and
Breakpoint (FPB) unit, is a hardware feature that allows for modifying or redirecting the
execution of code or data in flash memory at runtime,
A Data Watch point in ARM processors is a debugging feature that allows developers to
monitor changes to specific memory locations or variables, halting execution when a
specified access (read, write, or read/write) occurs at that data address, unlike breakpoints
which halt on instruction execution.
High Performance: Cortex-A processors are designed to deliver high levels of performance,
making them suitable for applications that require significant computing power.
Multicore Support: Many Cortex-A processors are designed to support multiple cores,
allowing for parallel processing and improved overall performance.
Advanced Power Management: Cortex-A processors typically incorporate advanced power
management features to optimize energy consumption without sacrificing performance.
64-bit Architecture: Many recent Cortex-A processors feature a 64-bit architecture, enabling
them to address larger amounts of memory and handle more complex computations.
Cortex-A series offers a wide range of cores starting from Cortex-A5 to Cortex-A77, each
core is designed in a way to fit into a wide range of applications.
Cortex A5:
o The Cortex A5 is the smallest processor of the A-range, but it can still demonstrate
multicore performance.
Cortex-A7:
Cortex-A9:
Cortex-A15:
o Designed for higher performance and introduced features like out-of-order execution.
Cortex-A53:
Cortex-A57:
Cortex-A72:
Cortex-A77:
The ARM Cortex-M class processors are a family of group of 32-bit RISC ARM
cores designed by ARM Holdings, a semiconductor intellectual property (IP)
company.
These processors are specifically made for use in microcontrollers and embedded
systems, offering a balance between performance, power efficiency, and simplicity.
The Cortex-M processors are widely used in various applications, including Internet
of Things (IoT) devices, automotive systems, industrial control systems, and
consumer electronics.
Cortex-M processors are designed to minimize power consumption while providing adequate
performance for embedded applications.
Harvard Architecture:
Cortex-M processors typically feature a Harvard architecture with separate instruction and
data buses. This architecture allows simultaneous access to instructions and data, improving
overall throughput.
The Cortex-M processors support the Thumb instruction set, which is a compressed 16-bit
instruction set designed to reduce code size. Additionally, later versions of Cortex-M
processors support the Thumb-2 instruction set, which includes a mix of 16-bit and 32-bit
instructions for improved code density and performance.
Cortex-M processors include features for efficient interrupt handling, making them well-
suited for real-time applications.
Embedded Systems
Automotive Systems
Medical Devices
Communication Devices
It is a 32-bit processor.
The Key characteristics of M0 processor:
Processor pipeline: The Cortex-M0 processor has a three-stage pipeline (fetch, decode, and
execute)
Interrupt Handling: The processors include a built-in interrupt controller called the Nested
Vectored Interrupt Controller (NVIC). This unit handles interrupt prioritization and masking
functions.
ARCHITECTURE OF M0 PROCESSOR:
When an interrupt request is detected, the WIC informs the power management to
power up the system so that the NVIC and the processor core can then handle the rest
of the interrupt processing.
A NVIC is used to manage the interrupts from multiple interrupt sources. NVIC is
closely integrated with the processor core to achieve low-latency interrupt processing
and efficient processing of late-arriving interrupts.
Debug Subsystem:
The debug subsystem contains various functional blocks to handle debug control,
program breakpoints, and data watchpoints.
When a debug event occurs, it can put the processor core in a halted state so that
embedded developers can examine the status of the processor at that point.
The JTAG or Serial Wire interface units provide access to the bus system and
debugging functionalities.
The internal bus system, data path in the processor core, and the AHB (Advanced
High-Performance Bus)-Lite bus interface is all 32-bit wide. AHB-Lite is an on-chip
bus protocol used in many ARM processors.
This bus protocol is part of the AMBA (Advanced Microcontroller Bus Architecture)
specification, which is a bus architecture developed by ARM and widely used in the
IC design industry.
3. Load/Store Instructions
4. Branch Instructions
[Link]– Add two registers / Register and an immediate value with carry
[Link]– Subtract two registers / Register and an immediate value with barrow
The instruction MOV rd, rn is an assembly language instruction that copies the value from
one register (rn) to another register (rd).
10. CMP – Compare two registers or register vs immediate to set status flags
Branch Instructions
B: Branch
1. MRS – Move PSR (Program Status Register) contents to general purpose register
The ARM instruction ADD rd, rn adds the value in register rn to itself and stores the result
in register rd.
The ADD rd, imm instruction is used in assembly languages, to add an immediate value to a
register and store the result in another register.
The instruction SUB rd, rn is an ARM assembly instruction that performs a subtraction. It
subtracts the value in register rn from the value in register rd, and stores the result back into
register rd.
The SUB rd, imm assembly instruction subtracts an immediate value from a register and
stores the result in another register.
The instruction MUL rd, rn is an ARM assembly language instruction that performs a
multiplication operation. It multiplies the value in register rn by the value in another
unspecified register. The result of this multiplication is then stored in register rd.
The instruction MUL rd, rn is an ARM assembly language instruction that performs a
multiplication operation. It multiplies the value in register rn by the value in register rm (not
specified in the query but implied by the usage of MUL rd, rn, rm in most documentation)
and stores the least significant 32 bits of the result in register rd
The basic syntax is ADC Rd, Rn, Rm where Rd is the destination register, Rn is the first
source register, and Rm is the second source register.
Add with Carry(ADC) : The ADC rd, rn instruction performs an add with carry operation in
ARM assembly language. It adds the value in register rn to the value in another register
(implied or specified, depending on the specific instruction variant) and also includes the
carry flag's value in the addition. The result of this addition is then stored in the destination
register rd.
Subtract with carry (SBC): The SBC rd, rn instruction in ARM assembly represents
"Subtract with Carry" and performs a subtraction operation on two registers, taking into
account the carry flag. Specifically, it subtracts the value in register rn and the complement of
the carry flag from the value in register rd, storing the result in rd.
In ARM assembly, "AND rd, rn" typically represents a bitwise AND operation where the
result is stored in register rd, and the operands are rn and an immediate value or another
register. Specifically, rd is the destination register, and rn is one of the source registers in the
operation.
The instruction MOV rd, rn is a data processing instruction in assembly language that copies
the value from a source register rn to a destination register rd
The instruction CMP rn, rm is a ARM assembly language instruction that compares the value
in register rn with the value in register rm. It subtracts the value of rm from rn and updates
the condition flags in the CPSR (Current Program Status Register) based on the result, but
discards the result of the subtraction.
CMN rn, rm : The instruction compares the value in register "rn" with the value in register
"rm" by performing an addition, but discards the result.
The LSLS rd, rm instruction in ARM assembly performs a logical left shift on the value in
register rm and stores the result in register rd, updating the condition flags based on the result.
Ex: If rm contains the value 0x00000003 (binary 00000000 00000000 00000000 00000011)
and rd is specified as r0 then after the LSLS r0, rm instruction, r0 will contain the
value 0x0000000C (binary 00000000 00000000 00000000 00001100). The N flag (Negative)
and Z flag (Zero) in the CPSR will be updated based on the result.
The assembly instruction LSRS rd, rm, rs performs a logical right shift operation on the value
in register rm and stores the result in register rd. The shift amount is determined by the least
significant byte of register rs
The ARM instruction ASLS Rd, Rm, #sh or ASLS Rd, Rd, Rs refers to an Arithmetic Shift
Left (ASL) operation in the Thumb instruction set, specifically with the S suffix indicating
that the condition code flags will be updated.
Load Register (LDR): The ARM assembly instruction LDR dr, [rn, imm] is used to load a
word (32 bits) from memory into a register. dr represents the destination register, rn is the
base register, and imm is an immediate offset. The memory address is calculated by adding
the value in rn to the immediate value imm
[rn, imm]:This is the addressing mode. It specifies how the memory address is calculated.
rn: This is the base register. The value in this register is used as the starting point for
calculating the memory address.
imm: This is an immediate offset. It is a constant value that is added to the base register's
value to form the final memory address.
LDRH: This is the instruction mnemonic, indicating a Load Register Halfword operation.
rd: This is the destination register where the loaded halfword will be stored. It's a general-
purpose register.
rn: This is the base register. The value in this register is used as the base address.
imm: This is a signed immediate value (an offset) that is added to the base address.
Store Register(STR) : The instruction STR rd, [rn, imm] is an ARM assembly language
instruction that stores the value from a register rd into memory. The memory address is
calculated by adding an immediate offset imm to the value in register rn.
Branch Instructions
It's used for direct jumps, such as to the beginning of a loop or to skip over a section
of code.
Branch with Link (BL): The BL instruction is used for subroutine calls (also known as
function calls). It not only jumps to the specified address but also stores the address of the
instruction immediately following the BL instruction in the Link Register (LR or R14).
The BLX instruction in ARM architecture stands for "Branch with Link and Exchange
instruction set." It is a crucial instruction used for calling subroutines and managing
transitions between the ARM (A32) and Thumb (T32) instruction sets.
POP: The POP instruction retrieves data from the top of the stack and places it into a
designated register. The stack pointer is adjusted accordingly to reflect the removal of data.
PUSH: The PUSH instruction saves data (registers, etc.) onto the stack.
In ARM processors, the MRS instruction (Move to Register from Special register) is used to
transfer the contents of a special program status register (PSR) into a general-purpose
register.
The primary function of MSR is to transfer data from a general-purpose register to a special
register.
Load-Exclusive (LDREX): Loads a value from memory and marks the memory location as
exclusively accessed by the current processor.
In ARM processors, LDM (Load Multiple) and STM (Store Multiple) are instructions that
allow for efficient transfer of multiple registers to or from memory with a single instruction.
In ARM processors, LDRT and STRT are instructions used for loading and storing data
from memory, respectively.
NOTE: The CPSR (Current Program Status Register) T bit, or Thumb bit, determines
the processor's current execution state. When T=1, the processor is in Thumb state, using 16-
bit instructions, and when T=0, it's in ARM state, using 32-bit instructions.
16-bit Instructions: Unlike the 32-bit instructions in the ARM instruction set, Thumb
instructions are 16 bits long. This reduction in instruction size allows more instructions to fit
into the same amount of memory, thereby increasing code density.
Reduced Instruction Set: The Thumb instruction set includes a subset of the instructions
available in the ARM instruction set. While the Thumb instruction set sacrifices some
functionality compared to ARM instructions, it still provides a wide range of operations
necessary for typical application tasks.
Limited Addressing Modes: Thumb instructions typically use a reduced set of addressing
modes compared to ARM instructions. This simplification helps in reducing the complexity
of the instruction set and achieving higher code density.
Thumb-2 Extension: In addition to the original Thumb instruction set, ARM introduced
Thumb-2, which extends the Thumb instruction set with additional 32-bit instructions.
Thumb-2 combines the benefits of both Thumb and ARM instruction sets, providing
improved code density while retaining the flexibility and functionality of the ARM
architecture.
Move (MOV):
MOV Rd, Rs: Moves the value from register Rs to register Rd.
Example: MOV R0, R1 copies the value from register R1 to register R0.
Add (ADD):
ADD Rd, Rs, Rn: Adds the values from registers Rs and Rn and stores the result in register
Rd.
Example: ADD R2, R3, R4 adds the values from registers R3 and R4 and stores the result in
register R2.
Subtract (SUB):
SUB Rd, Rs, Rn: Subtracts the value of register Rn from the value of register Rs and stores
the result in register Rd.
Example: SUB R5, R6, R7 subtracts the value of register R7 from the value of register R6
and stores the result in register R5.
Load (LDR):
LDR Rd, [Rn, #offset]: Loads a word from memory at the address specified by the sum of
the value in register Rn and the offset, and stores it in register Rd.
Example: LDR R0, [R1, #4] loads a word from memory at the address stored in R1 plus 4
bytes and stores it in R0.
Store (STR):
STR Rd, [Rn, #offset]: Stores the value in register Rd into memory at the address specified
by the sum of the value in register Rn and the offset.
Example: STR R2, [R3, #-8] stores the value in R2 into memory at the address stored in R3
minus 8 bytes.
Branch (B):
Example: BNE error handler branches to the instruction labelled "error handler" if the
previous comparison resulted in a non-equal condition.