Module 12 Part 1
Module 12 Part 1
PROTOCOLS
1 Bharghavi Y
CONTENTS
2 2 AHB PROTOCOL
2 Introduction 14
2.1 AHB Block diagram 16
2.2 Types of transfers 17
2.3 Signal Description 17
2.4 Basic Transfers 18
2.5 Burst Operation 21
2.6 Protection Control 24
2.7 Memory types 25
2.8 Bus Interconnection 26
2.9 Interconnect with AHB interface 27
2.10 Slave response signaling 28
2.11 Error Response 28
2.12 Exclusive Transfers 31
2.13 Interview Questions 33
3 3 AXI PROTOCOL
3 Introduction 35
3.1 Architecture 35
3.2 Channel Definition 36
2 Bharghavi Y
3.3 Signal Description 37
3.4 Channel Handshake 40
3.5 Dependencies between channel handshake signals 42
3.6 System-level Caches and Protection Units 46
3.7 Atomic Access 48
3.8 Response signaling 50
3.9 Ordering Model 51
3.10 Data Buses 53
3.11 Unaligned Transfers 53
3.12 Interview Questions 57
4 4 DMA PROTOCOL
4 Introduction 59
4.1 What is DMA 59
4.2 What is actually DMA 59
4.3 DMA signals 59
4.4 DMA Channels 60
4.5 Modes of DMA operation 60
4.6 DMA operational modes and settings 60
4.7 Types 60
4.8 Working of DMA controller 60
4.9 Bus-Master DMA devices 61
4.10 System DMA Devices 61
4.11 Interview Questions 63
3 Bharghavi Y
5.7 Clock polarity and Phase 67
5.8 Registers 68
5.9 Configuration of Master and Slave 73
5.10 Interview Questions 75
6 UART
6 Introduction 76
6.1 Why UART 76
6.2 Block diagram 76
6.3 Serial connector 77
6.4 Transmitter section 77
6.5 Receiver Section 77
6.6 UART TxD 78
6.7 UART RxD 79
6.8 How UART works 80
6.9 Transmission and reception 81
6.10 Configuration 81
6.11 Interview Questions 84
7 I2C
7 Introduction 85
7.1 Design 85
7.2 Interface 86
7.3 How I2C works 87
7.4 Types of transactions in I2C 87
7.5 Timing Diagram 88
7.6 Clock stretching 88
7.7 I2C Node device’s 89
7.8 Interview Questions 90
4 Bharghavi Y
AMBA
(ADVANCED MICRO-CONTROLLER BUS ARCHITECTURE)
The diagram depicts a block diagram of a AMBA Architecture. The High-performance ARM processor is the
Core of the system.
The other components like High-bandwidth on-chip RAM, DMA bus master and High-bandwidth memory
interface are connected to the Core by system bus, which is AHB in this case.
The other low bandwidth peripherals like UART, Timer, Keypad, and PIO are connected to the bus through the
bridge by using peripheral bus, here it is APB bus.
In this scenario, the bridge acts as the AHB slave corresponding to the core master. And it also acts as the APB
Master corresponding to remaining low-bandwidth external peripherals.
5 Bharghavi Y
APB
(Advanced Peripheral Bus)
1. Introduction
Advanced Peripheral Bus (APB) is the part of the Advanced Micro-controller Bus Architecture
(AMBA) family protocols.
It is a low-cost interface and it is optimized for minimal power consumption and reduced interface
complexity.
It is Non-Pipelined protocol, used to connect low-bandwidth peripherals.
Mostly used to connect the external peripheral to the SoC.
In APB, every transfer takes at least two clock cycles (SETUP cycle and ACCESS cycle) to complete.
It can also interface with AHB and AXI protocol’s using the bridges in between.
PERIPHERAL
It is external or internal device that connects to CPU to provide input, output.
6 Bharghavi Y
up to 32 bit wide.
PWRITE Master 1 The signal indicates an
(Requester) APB write access when
HIGH and an APB read
access when LOW.
PWDATA Master DATA_WIDTH Write data bus from
(Requester) master to slave, can be
up to 32 bit wide. The
PWDATA write data
bus is driven by the
APB bridge when
PWRITE is high .
PRDATA Slave DATA_WIDTH Read data bus from
(Completer) slave to master, can be
up to 32 bit wide. The
PRDATA read data bus
is driven by the APB
peripheral bus slave
when PWRITE is LOW.
PREADY Slave 1 The APB peripheral
(Completer) slave uses this signal to
extend an APB transfer.
PSLVERR Slave 1 This signal indicates
(Completer) transfer success or
failure. PSLVERR is
HIGH when PSELx,
PENABLE, PREADY
are high else becomes
LOW.
PSTRB Master DATA_WIDTH/8 PSTRB (write strobe)
(Requester) shows which bytes of
PWDATA are valid
during a write.
Each bit of PSTRB
controls one byte (8
bits) of the data bus —
PSTRB[n]→PWDATA[
(8n+7):(8n)]. It is used
only for writes and must
stay inactive during
reads.
7 Bharghavi Y
PPROT Master 3 PPROT defines the
(Requester) protection level of an
APB transfer — it
shows whether the
access is normal or
privileged, secure or
non-secure, and whether
it’s a data or instruction
access.
Let’s see how a typical write and read transfers are done in APB protocols
Write Transfers: This section describes the following types of write transfer
With no wait states
With wait states
8 Bharghavi Y
During an ACCESS phase, when PENABLE is high, the APB peripheral extends the transfer by driving
PREADY low.
The following signals remain unchanged while PREADY remains low:
Address signal, PADDR
Direction signal, PWRITE
Select SIGNAL, PSELx
Enable signal, PENABLE
Write data signal, PWDATA
PREADY can take any value when PENABLE is low.
This ensure that peripherals that have a fixed two cycle access can tie PREADY high.
Write Strobe
PSTRB tells which bytes in the write data (PWDATA) are valid during a write.
Each bit of PSTRB controls one byte (8 bit) – PSTRB[n] – PWDATA [(8n+7): (8n)].
If PSTRB[n] = 1, that byte is written: if 0, it’s ignored.
For read transfers, all PSTRB bits must be LOW.
Read Transfer: Two types of read transfer are described in this section
With no wait states
With wait states
At T1, a READ transfer with address PADDR, PWRITE and PSEL starts.
They will be registered at rising edge of PCLK.
This is SETUP Phase of the transfer.
After T2, PENABLE and PREADY are registered at the rising edge of PCLK.
When asserted, PENABLE indicates the starting of ACCESS phase.
When asserted, PREADY indicates that slave can complete the transfer at next rising edge of PCLK by
providing the data on PRDATA.
Slave must provide the data before the end of read transfer .[Link] T3.
9 Bharghavi Y
With wait states
During the ACCESS Phase, when PENABLE is high, the slave extends the transfer by driving
PREADY low.
The PADDR, PWRITE, PSEL, PENABLE, PPROT signals should remain unchanged while PREADY
is low.
1.4 Error Response
Two types of Error response: 1. Error write response and 2. Error read response.
PSLVERR is an APB signal that indicates an error during a transfer (read or write).
It is valid only when PSEL, PENABLE, and PREADY are all high (the last cycle of the transfer).
It is recommended to keep it low otherwise, if an error occurs
A write may or may not have updated the peripheral.
A read may return invalid data
Some peripherals don’t support errors, in that case, PSLVERR is just tied low (no errors ever signaled).
Example of a failing write transfer that completes with an error.
A read transfer can also complete with an error response, indicating that there is no valid read data available.
10 Bharghavi Y
1.5 APB STATES
The APB Protocol operates in three operating states:
1. Idle
2. Setup
3. Access
1. IDLE: The default or “resting” state of the APB bus. No transfer is happening.
PSEL = 0 (no peripheral selected).
11 Bharghavi Y
STATE WHAT HAPPENS KEY SIGNAL
IDLE No transfer PSEL =0
SETUP Address / control setup PSEL = 1, PENABLE = 0
ACCESS Data transfer PSEL = 1, PENABLE = 1, wait
for PREADY
Features
1. Part of AMBA family
2. Simple, non-pipelined protocol
3. Low power and low cost
4. Synchronous operation
5. Used for low-bandwidth peripherals
6. Bridge-based connection
7. Supports both read and write transfers
8. Error reporting supported
9. Byte-level write control
10. Protection signaling
11. Deterministic timing
12 Bharghavi Y
1.6 Interview Questions
21. How many cycles to take complete the Transfer? And why?
13 Bharghavi Y
AHB
2 Introduction
Advanced High-Performance Bus (APB) is the part of the Advanced Micro-controller Bus Architecture
(AMBA) family protocols.
It’s widely used in SoC(System-on-Chip) designs to connect multiple IP blocks like CPUs, memory interface’s
and peripheral’s.
It defines master, interconnect and slave.
AHB supports the efficient connection of processors, on-chip memories and off-chip external memory.
Interfaces with low-power peripheral macro cell functions.
It implements the features for high performance, high clock frequency.
1. Burst transfers
2. Single clock edge operation [due to pipeline]
3. Non – Tristate implementation
4. Configurable data bus width [1024]
5. Configurable address bus width.
1. Burst transfer:
AHB supports burst transferable which allow multiple data transfers to happen back-to-back With-out
restoring the address phase each time. It improves throughput and efficiency.
Example – If CPU wants to read 4 words of data from memory. It can use a INCR4 burst instead of
sending 4 separate read request.
3. Non-tristate implementation:
AHB does not used tristate bus. We used mux for data routing, making the bus safe and synthesizable.
AHB component’s
1. AHB Master : (Transfer initiator)
2. AHB Slave
3. AHB Arbiter : (Multi-master)
4. AHB Decoder : (Centralized decoder)
14 Bharghavi Y
2.1 AHB BLOCK DIAGRAM
1 master and 3 slaves which has 1 interconnect logic which include decoder and mux.
Decoder check the address sent by master and generate HSELx signal for selectng the slave
Mux routes the data output from selected slave to master.
If 1 master and 1 slave then no need decoder and mux.
If multiple master and multiple slave then we used interconnect (arbitation logic).
1 master and multiple slave we used 1 decoder and 1 mux is used.
1. Manager / Master
A Master provides address and control information to initiate read and write operations.
15 Bharghavi Y
2. Subordinate / Slave
A Slave responds to transfers initiated by masters in the system. The slave uses the HSELx select signal
from the decoder to control when it responds to a bus transfer.
3. Interconnect
The interconnect connects masters and slaves in a system.
In a single-master system, only a decoder and multiplexor are needed.
In a multi-master system, the interconnect handles arbitration and signal routing (address, control
& data) between multiple masters and slaves.
4. Decoder
The decoder identifies which slave is selected for each transfer based on the address.
It generates select signal signals (HSELx) for the appropriate slave.
Also provides control signals to the multiplexor.
5. Multiplexor
The multiplexor connects data and response signals from multiple slaves back to the master.
It selects the correct slave’s output (read, data, response) based on the decoder’s control.
A single centralized multiplexor is used when there are two or more slaves.
Operation
The master starts a transfer by driving address and control signals.
These signals define:
Address and direction (read/write).
Data width.
Type of transfer (single or burst).
16 Bharghavi Y
2.2 Types of transfers
Single – One data transfer.
Incrementing burst – Address increases after each transfer.
Wrapping burst – address wraps around at boundary limits.
Data movement
Write : data moves master – slave
Read : data moves slave – master
Transfer Phases
Address Phase – 1 cycle (address + control).
Data Phase – 1 or more cycles (actual data transfer.
Control Signals
HREADY – When low, it inserts wait states to give more time for data.
HRESP – Indicates success or failure of a transfer.
17 Bharghavi Y
0=no protection, 4=basic protection, 7=full
protection.
15. HMASTL master 1 Indicates that the current transfer is part of a
OCK locked sequence. It has the same timing as
address & control signal.
16. HNONSEC Master & 1 Indicate whether the transfer is non-secure or
decoder secure.
In AHB normal operation, a master usually completes an entire burst before the arbiter switches to another
master. However, the arbiter can interrupt a burst to reduce latency, requiring the master to re-arbitrate to
finish the burst. During writes, the master holds data stable through extended cycles, while for reads, the
slave only provides valid data when the transfer is about to complete.
HWRITE is high, it indicates a write transfer and the master broadcasts data on the write data bus,
HWDATA.
HWRITE is low, a read transfer is performed, and the slave must generate the data on the read data bus,
HRDATA.
The transfer consists of one address cycle and one data cycle.
18 Bharghavi Y
Transfer types (HTRANS)
19 Bharghavi Y
T0-T1: The 4-beat read starts with a NONSEQ transfer.
T1-T2: The Master is unable to perform the second beat and inserts a BUSY transfer to delay the start of the
second beat. The Slave provides the read data for the first beat.
T2-T3: The Master is now ready to start the second beat, so a SEQ transfer is signaled. The Master ignores any
data that the Slave provides on the read data bus.
T3-T4: The Master performs the third beat. The Slave provides the read data for the second beat.
T4-T5: The Master performs the last beat. The Slave is unable to complete the transfer and uses HREADYOUT
to insert a single wait state.
T5-T6: The Slave provides the read data for the third beat.
T6-T7: The Slave provides the read data for the last beat.
Locked Transfer
Locked transfers in AHB use the HMASTLOCK signal to make a transfer sequence indivisible, meaning no
other transfers can occur in between. This is often used for operations like semaphores to keep data consistent.
The bus locks when HMASTLOCK, HSEL, and HREADY are all HIGH.
It unlocks when HMASTLOCK goes LOW and HREADY is HIGH.
Most slaves don’t need HMASTLOCK since they handle transfers in order. Slaves shared by multiple
masters (like a multi-port memory controller) must support it.
A master can assert HMASTLOCK during IDLE transfers (before, during, or after a locked sequence),
but this is not recommended because it can disrupt arbitration.
All transfers in a locked sequence must go to the same slave address region.
Transfer size
HSIZE[2:0] indicates the size of a data transfer.
HSIZE [2] HSIZE [1] HSIZE [0] SIZE (bits) Description
0 0 0 8 BYTE
0 0 1 16 HALFWORD
0 1 0 32 WORD
0 1 1 64 DOUBLE WORD
1 0 0 128 4-WORD LINE
20 Bharghavi Y
1 0 1 256 8-WORD LINE
1 1 0 512 16-WORD LINE
1 1 1 1024 32-WORD LINE
The HSIZE signal defines the number of bits in each data transfer.
It helps slaves/memory interfaces prepare for the correct amount of data width in a transaction.
The HSIZE signals have the same timing as the address bus. However, they must remain constant throughout a
burst transfer.
HSIZE in conjunction with HBURST determines the address boundary for wrapping bursts.
The HBURST signal defines how many beats (data transfers) are in the burst and the behavior (wrap-
ping or incrementing).
Incrementing bursts simply increase the address.
Wrapping bursts wrap around to a lower boundary when reaching the end of the burst.
AHB supports single, 4-, 8-, 16-beat, and undefined-length bursts.
21 Bharghavi Y
Two burst types:
Incrementing burst: Address increases sequentially each transfer.
Wrapping burst: Address wraps around after reaching a boundary = (number of beats × transfer size).
Example: A 4-beat word (4-byte) wrapping burst wraps every 16 bytes — e.g., start at 0x34 → 0x34, 0x38,
0x3C, 0x30.
The HBURST[2:0] signals define the burst type.
Waited Transfers
Slaves use HREADYOUT to signal the master to wait if they need more time for data.
While waiting, the master can’t freely change the transfer type or address – there are specific limits on what can
change during these wait states.
22 Bharghavi Y
1. Transfer type changes during wait states
When the slave is requesting wait states, the master must not change the transfer type.
Idle transfer.
Busy transfer, fixed-length burst.
Busy transfer, undefined length burst.
Idle transfer
During a wait, the Manager can change HTRANS from IDLE to NONSEQ, but once it does, it must keep
HTRANS unchanged until HREADY = HIGH.
23 Bharghavi Y
T0–T1: Manager starts next INCR4 beat to 0x24.
T1–T3: Adds a BUSY transfer to 0x28; Subordinate holds HREADYOUT = LOW (wait).
T3–T4: Manager changes to SEQ and starts next beat to 0x28.
T4–T6: With HREADY LOW, HTRANS stays the same.
T5–T6: Beat to 0x24 finishes (HREADY HIGH).
T6–T7: Beat to 0x28 finishes; next beat starts to 0x2C.
24 Bharghavi Y
- - - 1 Data access
- - 0 - User access
- - 1 - Privileged access
- 0 - - Non-bufferable
- 1 - - Bufferable
0 - - - Non-cacheable
1 - - - Cacheable
The HPROT control signals have the same timing as the address bus. However, they must remain constant
throughout a burst transfer.
25 Bharghavi Y
1: Privileged access
Hint: HPROT [0] is just a hint and may not always be exact.
Interconnect
Interconnect connects Managers (Masters) and Subordinates (Slaves) in a system.
Single Manager system: uses only a Decoder and a Multiplexor to connect to Subordinates.
Multi-Manager system: needs an Interconnect that handles
o Arbitration (decides which Manager can use the bus)
o Routing (sends address, control, and data to the right Subordinate).
o Multi-layer AHB systems allow multiple Managers to work in parallel (details in ARM DVI 0045).
Address decoding
Address Decoder generates HSELx signals to select each Subordinate (Slave).
Use simple decoding for faster operation.
A Subordinate samples HSELx, address, and control signals only when HREADY = HIGH.
If HREADY = LOW, HSELx might change before the transfer ends.
Each Subordinate gets a minimum 1KB address space, aligned to 1KB boundaries.
Bursts never cross a 1KB boundary, ensuring correct decoding.
Default Subordinate
Used when some address spaces are unused in the memory map.
If a transfer goes to a nonexistent address, the default Subordinate gives an ERROR for NONSEQ/SEQ
transfers.
For IDLE/BUSY transfers, it gives an OKAY response with zero wait state.
26 Bharghavi Y
Multiple Subordinate Select (HSELx)
A single Subordinate can have multiple HSELx signals, each for a different address range.
Each logical interface needs at least 1KB address space.
This allows one Subordinate to handle multiple address regions (like data path and control registers)
without extra decode logic.
Read data and response multiplexor
The AHB protocol is used with a read data multiplexor interconnection scheme.
The Manager drives out the address and control signals to all the Subordinates, with the decoder selecting
the appropriate Subordinate during the data phase of the transfer.
Any response data from the selected Subordinate, passes through the read data multiplexor to the Man-
ager.
27 Bharghavi Y
An interconnect with AHB interfaces connects Managers and Subordinates.
The Manager side uses HTRANS to show valid transfers and a single HREADY to handle wait states
or arbitration delays.
The Subordinate side has HSEL and two HREADY signals:
HREADYOUT (from Subordinate) tells Managers to wait.
HREADY (from interconnect) can pause the Subordinate if needed.
Alternatively, HSEL can always be HIGH, and the interconnect sets HTRANS = IDLE for unused Sub-
ordinates.
Transfer done
A successful completed transfer is signaled when HREADY is HIGH and HRESP is OKAY.
Transfer pending
A Subordinate uses HREADYOUT to add wait states during a transfer.
When done, it sets HREADYOUT=HIGH and HRESP=OKAY to show the transfer finished successfully.
28 Bharghavi Y
In the second cycle, HREADYOUT = HIGH to finish, and HRESP stays HIGH (still ERROR).
The 2-cycle delay gives the Manager time to stop the next transfer.
If more time is needed, the Subordinate can add extra wait states first with HREADYOUT = LOW and
HRESP = OKAY.
Endianness
AHB supports little-endian and big-endian systems:
BE8 (byte-invariant big-endian): 8-bit accesses use the same bus bits as little-endian.
BE32 (word-invariant big-endian): 32-bit accesses use the same bus bits for MS and LS bytes as little-
endian.
AHB5 uses the Endian property to specify which big-endian form is used.
29 Bharghavi Y
The equations use the following variables:
Address The address of the transfer.
Data_Bus_Bytes The number of 8-bit data bus byte lanes.
INT(x) Rounded down integer value of x.
Little-endian:
LS byte goes to the transfer address.
Higher bytes go to increasing addresses.
Byte access uses Byte_Lane = Address % Data_Bus_Bytes.
Data is transferred on DATA[(8 × Byte_Lane) + 7 : (8 × Byte_Lane)]
30 Bharghavi Y
Transfer size Address offset DATA[31:24] DATA[23:16] DATA[15:8] DATA[7:0]
Word 0 Active[MS] Active Active Active[LS]
Halfword 0 - - Active[MS] Active[LS]
Halfword 2 Active[MS] Active[LS] - -
Byte 0 - - - Active
Byte 1 - - Active -
Byte 2 - Active - -
Byte 3 Active - - -
Reset (HRESETn):
Active LOW, can be asserted asynchronously, but released synchronously with HCLK.
Must be asserted long enough to fully reset components.
During reset:
Managers keep address/control signals valid and HTRANS = IDLE.
Subordinates set HREADYOUT = HIGH.
31 Bharghavi Y
Exclusive access signals:
HEXCL: Marks a transfer as part of an Exclusive sequence.
HMASTER: Identifies the Manager/thread; ensures uniqueness for the monitor.
HEXOKAY: Shows if the Exclusive transfer succeeded.
Notes: HMASTER width varies (recommendation: 4 bits for interconnect, 8 bits for Subordinate/monitor).
HMASTER must be valid for all transfers, not just Exclusive ones.
Response signaling
HEXOKAY signal:
High: Exclusive Transfer succeeded (Exclusive Write updated memory).
Low: Exclusive Transfer failed:
o Address doesn’t support Exclusive Transfers, or
o Memory changed since the matching Exclusive Read.
Rules:
Assert only when HREADY = HIGH.
Only used for Exclusive Transfers.
Must not be asserted in the same cycle as HRESP.
Note: If only one Manager accesses the location, the Subordinate can always signal success.
Calculation for wrap
lower boundary
(start_address / 2^HSIZE x HBURST) x 2^HSIZE x HBURST
upper boundary
lower boundary + 2^HSIZE x HBURST
32 Bharghavi Y
5. Networking equipment – Routers and switches use AHB for processor-memory-peripheral communication.
6. Industrial control systems – Connecting sensors, controllers, and actuators with reliable high-speed transfers.
7. Automotive electronics – Infotainment systems and advanced driver-assistance systems (ADAS) use AHB
for CPU-peripheral data exchange.
8. FPGA-based designs – AHB is used in custom SoCs implemented on FPGAs for rapid prototyping.
FEATURES APPLICATIONS
Single-clock synchronous bus. Embedded systems and SoC.
Supports multiple bus masters and slaves. ARM-based mircocontrollers and processors.
Separate read/write data buses for high throughput. Memory-mapped peripherals in high-performance
systems.
Pipelined operation to overlap address and data Multi-master systems requiring burst transfers.
phases.
ADVANTAGES DISADVANTAGES
High performance due to pipelining and burst More complex than APB.
transfers.
Flexible multi-master support with arbitration. Requires careful timing and signal stability design.
Easier integration with AMBA AXI/APB systems. Hardware cost and area overhead higher due to
pipelining and multiple signals.
Exclusive access support allows safe multi-master Implementation defined behaviors (like glitches
memory updates. between clock edges) may complicate verification.
33 Bharghavi Y
11. What is the role of HBURST?
12. How does HMASTER signal help in multi-master systems?
13. What is pipeline transfer in AHB?
14. How is a write transfer performed in AHB?
15. How is a read transfer performed in AHB?
16. Can AHB perform back-to-back read/write operations?
17. How does AHB support burst transfer?
18. How is data alignment handled in AHB?
19. What is the difference between single, incrementing, and wrapping burst transfers?
20. How does byte-enable work in AHB?
21. Explain HRESP signal in detail.
22. What are the SPLIT and RETRY responses in AHB?
23. What happens if a slave takes too long to respond?
24. How are error conditions indicated to the master?
25. What is the role of HREADYOUT from a slave?
26. How is exclusive access handled in AHB5?
27. What is the HEXOKAY signal used for?
28. What happens if two masters request the bus at the same time?
29. How does AHB handle multiple slaves?
30. Explain arbitration in AHB.
31. What are the different arbitration schemes used?
32. What is the difference between locked and unlocked transfers?
33. Explain endianness support in AHB.
34. What is byte-invariant vs word-invariant big-endian?
35. How does AHB handle split transactions?
36. How is burst transfer efficiency improved in AHB?
37. What is the purpose of separate read and write data buses?
38. Lower and upper boundary wrap calculation by giving starting address addr = 0x24, length = 8, transfer
size = 32bits?
34 Bharghavi Y
AXI
(ADVANCED EXTENSIBLE INTERFACE)
3 Introduction
AXI, the third generation of AMBA interface AMBA 3 specification, is targeted at high-performance, high
clock frequency system designs and suitable for high speed sub-micrometer interconnect :
Separate address/control and data phases.
Support for unaligned data transfers using byte strobes.
Burst based transactions with only start address issued and issuing of multiple outstanding addresses.
Easy addition of register stages to provide timing closure.
3.1 Architecture
35 Bharghavi Y
Each channel has:
– Information signals.
– Valid and ready handshake.
– AXI consists of five different channels
1. Write address channel
2. Write data channel
3. Write response channel
4. Read address channel
5. Read data channel
Each of the five independent channels consists of a set of information signals and uses a two-way VALID and
READY handshake mechanism.
The VALID signal shows that data or control info is ready.
The READY signal shows the receiver can accept the data.
36 Bharghavi Y
The LAST signal marks the final data transfer in a transaction.
37 Bharghavi Y
transfer.
AWCACHE[3:0] Master Cache and buffer attributes.
AWPROT[2:0] Master Protection level(privileged,
secure, instruction/data).
AWVALID Master Master says address/control info
is valid.
1 = address and control
information available
0 = address and control
information not available.
AWREADY Slave Slave says it’s ready to accept
the address.
1 = Slave ready.
0 = Slave not ready.
38 Bharghavi Y
BREADY Master Master ready to accept the
response.
39 Bharghavi Y
3.4 Channel Handshake
In the AXI protocol, the channel handshake is the process used to transfer data or control information between
the master and slave safely and efficiently.
Handshake process
All five channels use the VLAID/READY handshake for data and control transfer.
VALID (from source) shows data is ready.
READY (from destination) shows it can accept data.
Data transfers only when both are HIGH.
No direct (combinational) connection is allowed between input and output signals on master or slave.
40 Bharghavi Y
If VALID and READY are HIGH in the same cycle, the transfer happens immediately.
The individual AXI protocol channel handshake mechanisms are described in:
41 Bharghavi Y
Relationships between Channels
Write data can arrive before, with, or after the write address, depending on channel stages.
Interconnects must align address and write data to ensure it goes to the correct slave.
Read data must always follow its address.
Write response must always follow the last write data of its transaction.
The slave can wait for ARVALID to be asserted before it asserts ARREADY.
The slave must wait for both ARVALID and ARREADY to be asserted before it starts to return read
data by asserting RVALID. (Fig: 3-4)
Addressing Options
This chapter describes AXI burst types and how to calculate addresses and byte lanes for transfers
within a burst. It contains the following sections:
About addressing options:
AXI uses burst transfers, with the master sending the first address and control info.
The slave calculates addresses for the rest of the burst.
Bursts cannot cross 4 KB boundaries to stay within a single slave and simplify address calculation.
42 Bharghavi Y
Burst-length
The AWLEN or ARLEN signal specifies the number of data transfers that occur within each burst.
Burst Size
How the ARSIZE or AWSIZE signal specifies the maximum number of data bytes to transfer in each beat, or
data transfer, within a burst.
AXI uses the transfer address to select which byte lanes to use.
Incrementing/wrapping bursts use different lanes for each beat; fixed bursts use the same lanes.
43 Bharghavi Y
Transfer size cannot exceed the data bus width.
Burst Type
The AXI protocol defines three burst types described in:
1. Fixed burst
2. Incrementing burst
3. Wrapping burst
Fixed Burst
In a fixed burst, the address remains the same for every transfer in the burst. This burst
type is for repeated accesses to the same location such as when loading or emptying a peripheral FIFO.
Incrementing burst
In an incrementing burst, each transfer address increases from the previous one.
The increment amount equals the transfer size (e.g., +4 for 4-byte transfers).
Wrapping burst
A wrapping burst works like an incrementing burst but the address wraps around after reaching a set boundary.
The wrap boundary = transfer size × number of transfers.
Rules:
Start address must be aligned to the transfer size.
Burst length must be 2, 4, 8, or 16.
Burst Address
This section provides some simple formulas for determining the address and byte lanes of transfers within a
burst. The formulas use the following variables:
44 Bharghavi Y
Aligned_Address The aligned version of the start address.
Use this equation to determine the address of the first transfer in a burst:
Address_1 = Start_Address.
Use this equation to determine the address of any transfer after the first transfer in a burst:
Address_N = Aligned_Address + (N – 1) x Number_Bytes.
For wrapping bursts, the Wrap_Boundary variable is extended to account for the wrapping boundary:
Wrap_Boundary = (INT(Start_Address / (Number_Bytes x Burst_Length))) x (Number_Bytes x
Burst_Length).
Use these equations to determine which byte lanes to use for the first transfer in a burst:
Lower_Byte_Lane = Start_Address - (INT(Start_Address / Data_Bus_Bytes))
x Data_Bus_Bytes
Upper_Byte_Lane = Aligned_Address + (Number_Bytes - 1) -
(INT(Start_Address / Data_Bus_Bytes)) x Data_Bus_Bytes.
Use these equations to determine which byte lanes to use for all transfers after the first
transfer in a burst:
Lower_Byte_Lane = Address_N – (INT(Address_N / Data_Bus_Bytes))
x Data_Bus_Bytes
Upper_Byte_Lane = Lower_Byte_Lane + Number_Bytes – 1.
45 Bharghavi Y
3.6 System-level Caches and Protection Units
It contains the following sections:
Cache support
Protection unit support
Cache support
ARCACHE and AWCACHE signals give cache-related info for reads and writes.
They define if data can be buffered, cached, or allocated in the cache.
Bits meaning:
[0] Bufferable (B): Transaction can be delayed (mainly for writes).
[1] Cacheable (C): Data can be merged (writes) or prefetched/reused (reads).
[2] Read Allocate (RA): Allocate in cache on a read miss (only if C = 1).
[3] Write Allocate (WA): Allocate in cache on a write miss (only if C = 1).
– The encoding of the ARCACHE [3:0] and AWCACHE[3:0] signals.
46 Bharghavi Y
1 1 0 1 Reserved
1 1 1 0 Cacheable write-through, allocate on both
reads and writes
1 1 1 1 Cacheable write-back, allocate on both
reads and writes
AWPROT and ARPROT signals provide three levels of access protection to prevent illegal transactions in
complex systems.
This is used by some masters to indicate their processing mode. A privileged processing mode typically has a
greater level of access within a system.
This is used in systems where a greater degree of differentiation between processing modes is required.
47 Bharghavi Y
0 = secure access
[2] 1 = instruction access
0 = data access
AXI protocol implements exclusive access and locked access mechanisms. It contains the following sections:
About atomic accesses
Exclusive access
Locked access
To enable the implementation of atomic access primitives, the ARLOCK [1:0] or AWLOCK [1:0] signal
provides exclusive access and locked access.
Exclusive Access
Exclusive access allows semaphore-like operations without locking the bus, keeping speed and
bandwidth high.
ARLOCK/AWLOCK select exclusive access, and RRESP/BRESP show success or failure.
The slave needs extra logic to support it, and AXI includes a fail-safe if the slave doesn’t support
exclusive access.
A master starts exclusive access with an exclusive read, getting EXOKAY if the slave records the address.
Later, it does an exclusive write to the same address:
48 Bharghavi Y
If the address didn’t change, the write succeeds and returns EXOKAY.
If the address changed, the write fails and returns OKAY (no update).
If the master skips the write, the slave keeps monitoring until a new exclusive read starts.
The write must happen only after the read is complete.
A slave without exclusive access support ignores ARLOCK/AWLOCK and always returns OKAY.
A slave with exclusive access needs a monitor unit to track exclusive reads and writes.
The monitor records the address and ID of an exclusive read and watches for changes.
If an exclusive write matches the monitored address (no changes), it succeeds and returns EXOKAY.
If the address was changed or the monitor reset, the write fails and returns OKAY.
Exclusive write must match the size and length of its preceding exclusive read.
The address must be aligned and identical for both read and write.
ARID (read ID) must match AWID (write ID).
Control signals for both must be the same.
Transfer size must be a power of 2 (1–128 bytes), with 128 bytes max.
ARCACHE/AWCACHE must ensure the slave monitoring exclusivity sees the transaction (not
cacheable).
Ignoring these rules causes unpredictable behavior.
The slave must monitor at least the number of bytes in the transaction (up to 128 bytes).
BRESP [1:0] and RRESP [1:0] signals indicate the result of a transaction.
OKAY response shows a successful normal access.
EXOKAY response shows a successful exclusive access.
Slaves that do not support exclusive access return OKAY for exclusive access attempts.
Locked Access
ARLOCK [1:0] or AWLOCK [1:0] signals indicate a locked transfer.
During a locked transfer, only that master can access the slave region.
The interconnect arbiter enforces the lock.
A master must have no other outstanding transactions before starting a locked sequence.
A locked sequence must end with a final transaction that is not locked to remove the lock.
The final unlocking transaction must complete before any new transactions start.
All transactions in a locked sequence must use the same ARID or AWID.
49 Bharghavi Y
3.8 Response Signaling
The AXI protocol allows response signalling for both read and write transactions. For read transactions the
response information from the slave is passed alongside the read data itself, however for writes the response
information is conveyed along the write response channel.
In a write transaction, there is one response for the entire burst, not for each data item.
In a read transaction, the slave can give different responses for each transfer in a burst.
Even if an error occurs, all data transfers must still complete.
For example, if 8 reads are requested and an error happens, all 8 transfers still occur with error
responses.
The burst is not canceled after a single error.
Masters handling multiple outstanding addresses must be able to manage error responses from earlier
transfers while later ones continue.
Response Types
This section describes the four AXI protocol response types:
Normal access success
Exclusive access
Slave error
Decode error.
50 Bharghavi Y
Exclusive access
The EXOKAY response indicates the success of an exclusive access.
Slave error
The SLVERR response indicates an unsuccessful transaction. Examples of slave error conditions are:
FIFO/buffer overrun or under-run condition
Unsupported transfer size attempted
Write access attempted to read-only location
Timeout condition in the slave
Access attempted to an address where no registers are present
Access attempted to a disabled or powered-down function.
To simplify system monitoring and debugging, it is recommended that error responses are used only for error
conditions and not for signaling normal, expected events.
Decode error
A decode error (DECERR) happens when no slave exists for a given address.
The inter-connect sends the transaction to a default slave, which returns the DECERR response.
The default slave can log error details to help with debugging.
Even with a DECERR, all data transfers must still complete as per AXI rules.
How the AXI protocol uses transaction ID tags to enable the issuing of multiple outstanding addresses and out-
of-order transaction processing. It contains the following sections:
About the ordering model
Transfer ID fields
Read ordering
Normal write ordering
Write data interleaving
Read and Write interaction
Interconnect use of ID
Recommended width of ID fields
AXI allows out-of-order transaction completion and multiple outstanding addresses for better
performance.
These features help achieve high data throughput and system efficiency.
ID signals manage out-of-order transactions by treating each ID as a separate ordered stream.
Transactions with the same ID must stay ordered, but different IDs can complete in any order.
51 Bharghavi Y
The five transaction IDs are:
AWID The ID tag for the write address group of signals.
WID The write ID tag for a write transaction. Along with the write data, the master transfers a WID to
match the AWID of the corresponding address.
BID The ID tag for the write response. The slave transfers a BID to match the AWID and WID of the
transaction to which it is responding.
ARID The ID tag for the read address group of signals.
RID The read ID tag for a read transaction. The slave transfers an RID to match the ARID of the
transaction to which it is responding.
Masters can send multiple addresses without waiting for earlier ones to finish, allowing parallel processing.
Out-of-order completion lets faster transactions finish first, improving performance and reducing latency.
Transfer ID Fields
ID fields (ARID/AWID) let a master issue multiple independent transactions.
Different masters or different IDs can complete in any order.
Same ID (AWID or ARID) transactions must complete in order.
Reads with the same ARID must return in the order issued — handled by the slave or interconnect.
No fixed order between reads and writes with the same ID — the master must manage the order if
needed.
Read Ordering
Same ARID: Read data must return in the same order as issued.
Different ARIDs: Read data can return in any order or be interleaved.
Slave: Must return data with RID = ARID and keep order for the same ARID.
Interconnect: Ensures reads with the same ARID from different slaves complete in order.
Read reordering depth: Number of pending reads that can be reordered; if all are in order, depth = 1.
Read and write transactions can complete in any order — no built-in restrictions.
If a master needs order, it must wait for the earlier transaction to finish before starting the next.
A read is complete when the last read data is received.
A write is complete only when the write response (BRESP) is received.
52 Bharghavi Y
For peripherals, masters should wait for earlier transactions to complete before switching between read
and write.
For memory regions, a master can check addresses — if they don’t overlap, it can issue new transactions
immediately.
The inter-connect adds extra bits to master ID fields (ARID, AWID, WID) to make them unique.
Masters don’t need to know each other’s ID values.
Slave interfaces see wider ID fields than master interfaces.
For read data, the interconnect uses the extra RID bits to route data to the correct master and removes
them before delivering it.
Recommended Width of ID fields
Describes transfers of varying sizes on the AXI read and write data buses and how the interface uses byte-
invariant endianness to handle mixed-endian transfers.
It contains the following sections:
About the data buses
Write strobes
Narrow transfers
Byte invariance
Write Strobes
WSTRB signals indicate which bytes of the write data are valid.
One strobe per 8 bits of the write data bus.
A master must ensure that the write strobes are asserted only for byte lanes that can contain valid data as
determined by the control information for the transaction.
53 Bharghavi Y
Narrow Transfers
Narrow transfers use only certain byte lanes of the data bus.
In incrementing/wrapping bursts, the lanes change each beat; in fixed bursts, the lanes stay the same.
Byte Invariance
AXI uses byte-invariant endianness, so each byte always goes to the same data bus wires and memory
address.
Little-endian components connect directly; big-endian components need conversion.
Some data structures mix endianness, e.g., little-endian headers with a big-endian payload, so byte-
invariant access is needed.
54 Bharghavi Y
Byte invariance ensures that little-endian access to parts of the header information does not corrupt other
big-endian data within the structure.
Examples
Figure 10-1, Figure 10-2 on page 10-4, and Figure 10-3 on page 10-4 show examples of aligned and unaligned
transfers on buses with different widths. Each row in the figures represents a transfer. The shaded cells indicate
bytes that are not transferred, based on the address and control information
55 Bharghavi Y
Clock and Reset
Clock and reset requirements
This section gives the requirements for implementing the ACLK and ARESETn signals.
Clock
Each AXI component uses a single clock signal, ACLK. All input signals are sampled on the rising edge of
ACLK. All output signal changes must occur after the rising edge of ACLK.
There must be no combinatorial paths between input and output signals on both master and slave interfaces.
Reset
ARESETn is active LOW; can assert asynchronously, de-assert synchronously.
During reset: masters set ARVALID, AWVALID, WVALID LOW, slaves set RVALID, BVALID LOW; other
signals don’t matter.
A master interface must begin driving ARVALID, AWVALID, or WVALID HIGH only at a rising ACLK edge
after ARESETn is HIGH.
Figure 11-1 shows the first point after reset that ARVALID, AWVALID, or WVALID, can be driven HIGH.
56 Bharghavi Y
FEATURES APPLICATIONS
Burst-based transactions with only one address SoC designs for high-performance CPUs, GPUs,
DSPs
Supports unaligned data-transfer Memory controllers (DDR, SRAM, Flash
interfaces)
Separate the read and write channels Peripherals requiring high-speed data transfer
Supports optional low-power operation Multi-master systems where several masters share
common memory or peripherals
ADVANTAGES DISADVANTAGES
High performance Complexity
Separate read and write channels Resource usage
Flexible data width Potential for out-of-order data handling issues
Byte-level strobes and unaligned transfers Power consumption
57 Bharghavi Y
16. Lower and upper boundary wrap calculation by giving starting addr = 0x24, length = 8, transfer size =
32bits?
17. What is lock signal/exclusive access in AXI with respect to higher level?
18. Write an assertion on handshake signals – ready and valid, ready comes after 5 cycles from the start of
valid high? Difference between AHB and AXI?
19. Explain the Channel concept?
20. How does AXI differ from simpler bus protocols like AHB?
21. Describe the process of arbitration in AXI for accessing shared resources?
22. How does AXI handle data synchronization across multiple clock domains?
23. Describe the AXI protocol's support for multi-layer interconnects?
58 Bharghavi Y
DMA
(DIRECT MEMORY ACCESS)
4 Introduction
In many I/O interfacing applications and certainly in data acquisition systems, it is often necessary to transfer
data to or from an interface at data rates higher than those possible using simple programmed I/O loops.
Microprocessor controlled data transfers within the PC (using the IN (port) and OUT (port) instructions) require
a significant amount of CPU time and are performed at a significantly reduced data rate.
Further to this, the CPU cannot perform any other processing during program controlled I/O operations.
DREQ0-DREQ3-DMA Request: These are four independent, asynchronous input signals to the DMA
channels through peripherals such as floppy disks and the hard disk.
DACK0-DACK3-DMA Acknowledge: These are output lines to inform the individual peripheral that a
DMA is granted, DREQ and DACK are equivalent to handshake signals in I/O device’s.
AEN and ADSTB – Additives Enable and Address Length: These are active high output signals that
are used to latch a high-order address byte to generate a 16-bit address.
59 Bharghavi Y
4.4 DMA Channels
The 8237 DMA controller provided by IBM is a peripheral interface circuit for allowing peripheral
devices to directly transfer data to or from main memory.
It includes four independent channels and may be expanded to any number of channels by cascadinf
additional controller chips.
In the IBM architecture, two DMA controllers are used. One DMA controller is used for byte transfers,
and the second DMA controller is user for word (16-bit) transfers.
Single
A single byte (or word) is transferred. The DMA must release and re-acquire the bus for each
additional byte.
This is commonly-used by devices that cannot transfer the entire block of data immediately.
The peripheral will request the DMA each time it is ready for another transfer.
Block / Demand
Once the DMA acquires the system bus, an entire block of data is transferred, up to a maximum of 64k.
If the peripheral needs additional time, it can assert the READY signal to suspend the transfer briefly.
4.7 Types
Types of DMA
There are four popular types of DMA.
Single-Ended DMA: In this type, the DMA controller is connected only to one device (usually either
the memory or the I/O device), and it directly controls data transfer.
Dual-Ended DMA: The DMA controller is connected to both the source and the destination, typically
memory and an I/O device.
Arbitrated-Ended DMA: In the systems with multiple DMA devices or masters, arbitration is needed
to decide which device gets control of the bus. It is more advanced than Dual-Ended DMA.
Interleaved DMA: Interleaved DMA are those DMA that read from one memory address and write
from another memory address.
60 Bharghavi Y
How DMA works
steps:
1. Read from source
2. Write to destination
3. Increment/decrement pointers
4. Repeat until count=0
61 Bharghavi Y
Camera sensor → memory in phones
PCIe, AHB, AXI systems where data moves without CPU load
SSD reading/writing data
Embedded systems: ADC → Memory, UART → Memory, SPI → Memory
Features of DMA
Direct transfer between memory and peripherals.
CPU is free during transfer.
Supports burst transfers.
Uses DMA controller with channels and priority.
Interrupt-based completion signaling.
Supports scatter–gather, circular buffer, auto-reload modes (in advanced DMA).
Applications of DMA
Memory-to-Memory copy (fast data movement)
High-speed I/O devices: SPI, I2C, UART, ADC, DAC
Storage interfaces: SATA, PCIe, USB
Graphics: Copying frame buffers
Networking: Ethernet packet transfer
Sensors: Camera, audio codecs
ADVANTAGES DISADVANTAGES
High speed data transfer without slowing CPU. Adds extra hardware cost (DMA controller).
CPU can handle other tasks. DMA + CPU memory access may cause bus con-
tention.
Reduces CPU cycles – performance improve- More complex system design and debugging.
ment.
Efficient for large data transfers. Requires proper synchronization; otherwise data
corruption can occur.
Lower power usage since CPU is idle. Interrupt overhead if too many small transfers.
62 Bharghavi Y
4.11 Interview Questions
1. What is DMA?
2. Why do we need DMA?
3. Where is DMA used in real life?
4. What are the main signals/inputs of a DMA controller?
5. What are the types of DMA transfer modes?
6. What is Scatter-Gather DMA?
7. What is the difference between simple DMA and multi-Channel DMA?
8. What is DMA Arbitration?
9. What is DMA burst transfer?
10. How does DMA request and acknowledge mechanism work?
11. What is Memory-to-Memory vs Memory-to-peripheral transfer?
12. What are the key blocks inside a DMA controller?
13. What is address increment logic in DMA?
14. What is DMA chaining?
15. What is DMA descriptor?
16. What is DMA interrupt functionality?
17. What is DMA errors? What is cyclic stealing?
18. How does DMA work with AXI/AHB bus? What is the difference between DMA and CPU transfer?
63 Bharghavi Y
OFF-CHIP COMMUNICATION PROTOCOL
SPI
(SERIAL PHERIPHERAL INTERFACE)
5 Introduction
The Serial Peripheral Interface Bus or SPI bus is a synchronous serial data link standard named
by Motorola that operates in full duplex mode.
Devices communicate in master/slave mode where the master device initiates the data frame.
Multiple slave devices are allowed with individual slave select (chip select) lines.
During a data transfer the master always sends 8 to 16 bits of data o the slave, and the slave
always sends a byte of data to the master.
Maximum data bit rate is one eighth of the input clock rate.
One central device (Master), initiates communication with all slaves.
No address decoding logic required.
SPI master wishes to send the data to slave or request information from the slave, it activates
the clock signal.
Master generates information on one line (MOSI) while samples (read) from another line
(MISO).
64 Bharghavi Y
MOSI: (Master out Slave in Input/Output)
The MOSI signal is a unidirectional signal used to transfer serial data from the Master to the
Slave.
When a device is a master, serial data is output on this signal.
When a device is a slave, serial data is input on this signal.
5.2 Operation
The SPI bus can operate with a single master device and with one or more slave devices.
SPI bus: single master and single slave
If a single slave device is used, the SSEL pin may be fixed to logic low if the slave permits it.
Some slaves require the falling edge (high->low transition) of the slave select to initiate an
action such as the MAX1242 by Maxim, an ADC, that start conversion an said transition.
5.3 Configuration
Two types multiple slave configuration:
1. Typical SPI bus: Master and independent Slaves
1. Daisy-Chained SPI bus: Master and cooperative slaves.
65 Bharghavi Y
5.4 Typical SPI Bus
With multiple slave devices, an independent SSEL signal is required from the master for each
slave device (3).
In the independent slave configuration, there is an independent slave select line for each slave.
This is the way SPI is normally used.
Since the MISO pins of the slaves are connected together, they are required to be tri-state pins.
Points
Not have ack mechanism to confirm receipt of data and does not have flow control.
SPI master, not have knowledge of whether slave exist or not.
Not particular addressing scheme.
Not defined any maximum data rate.
66 Bharghavi Y
To begin a communication, the master first configures the clock, using a frequency less than or
equal to the maximum frequency the slave device supports.
Such frequencies are commonly in the range of 1- 7 MHZ.
The master then pulls the slave select SSEL low for the desired chip.
During each SPI clock cycle, a full duplex data transmission occurs.
The master sends a bit on the MOSI line; the slave reads it from that same line.
The slave sends a bit on the MISO line; the master reads it from that same line.
Transmission normally involve two shift registers of some given word size, such as eight bits,
one in the master and one in the slave; they are connected in a ring.
After that register has been shifted out, the master and slave have exchanged values.
Then each device takes that value and does something with it, such as writing it to memory.
If there are more data to exchange, the shift registers are loaded with new data and the process
repeats.
l Mode Numbers
The combinations of polarity and phases are often referred to as modes
MODE CPOL CPHA
0 0 0
1 0 1
2 1 0
3 1 1
68 Bharghavi Y
SPI Control Register
(S0SPCR – 0Xe002 0000)
BIT SYMBOL VALUE DESCRIPTION
1:0 - Reserved, user
software should not
write ones to reserved
bits.
2 Bit-Enable 0 The SPI controller
sends and receives 8
bits of data per
transfer.
The SPI controller
1 sends and receives
the number of bits
selected by bits 11:8
3 CPHA Clock phase control
0 Data is sampled on
the first clock edge of
SCK.
1 Data is sampled on
the second clock edge
of the SCK.
4 CPOL Clock phase control
0 SCK is active high.
1 SCK is active low.
5 MSTR Master mode select.
0 The SPI operates in
salve mode.
6 LSBF LSB First, controls in
which direction each
byte is shifted when
transferred.
0 SPI data is
transferred MSB (bit
7) first.
1 SPI data is
transferred LSB (bit
0) first.
7 SPIE Serial peripheral
interrupt enable.
0 SPI interrupts are
inhibited.
1 A hardware interrupt
is generated each
time the SPIF or
MODF bits are
activated.
11:8 When bit 2 of this
69 Bharghavi Y
register is 1, this field
controls the number
of bits per transfer:
1000 8 bits per transfer
1001 9 bits per transfer
1010 10 bit per transfer
1011 11 bits per transfer
1100 12 bits per transfer
1101 13 bits per transfer
1110 14 bits per transfer
1111 15 bits per transfer
0000 16 bits per transfer
15:12 - Reserved, user
software should not
write ones to reserved
bits.
There is no buffer between the data register and the internal shift register. A write to the data
register goes directly into the internal shift register.
Therefore, data should only be written to this register when a transmit is not currently in
progress.
Read data is buffered.
When a transfer is complete, the receive data is transferred to a single byte data buffer, where it
is later read.
A read of the SPI data register returns the value of the read data buffer.
70 Bharghavi Y
contain the additional
transmit and receive bits.
When less than 16 bits are
selected, the most significant
among these bits read as
zeroes.
71 Bharghavi Y
register.
72 Bharghavi Y
7:1 - Reserved, user software
should not write ones to
reserved bits.
5.9 Configuration
SPI can be configured as MASTER or SLAVE.
73 Bharghavi Y
Real life Usage
Consumer Electronics
Used in mobile phones for:
Flash memory (NOR/NAND)
Touchscreen controllers (fast sampling)
Display drivers (AMOLED / TFT)
Wi-Fi, Bluetooth, and GPS chips often communicate with the main processor via SPI.
Communication Modules
Used heavily in RF and wireless modules:
LoRa 433/868 MHz modules
NRF24L01 wireless transceiver
BLE modules
SPI provides high-speed configuration and data transfer.
Storage Devices
SD cards use SPI mode as an alternative to SDIO.
External EEPROM and Flash memories communicate over SPI.
ADVANTAGES DISADVANTAGES
Full duplex communication Requires more pins on IC packages than
I2C, even in the “3-wire” variant.
Higher throughput than I2C No hardware flow control
Complete protocol flexibility for the bits No hardware slave acknowledgment (the
transferred master could be “talking” to nothing and not
Not limited to 8-bit words know it)
Arbitrary choice of message size,
74 Bharghavi Y
content, and purpose
Extremely simple hardware interfacing Supports only one master device.
Typically lower power requirements Only handles short distance compared to
than I2C due to less circuitry RS-232, RS-485, or CAN-bus.
No arbitration or associated failure
modes
Slaves use the master’s clock, and
don’t need precision oscillators
Transceivers are not needed.
75 Bharghavi Y
UART
(UNIVRSAL ASYNCHRONOUS RECEIVER TRANSMITTER)
6 Introduction
A serial communication can be done using fewer wires as compared to its parallel counter part.
It is a cheapest communication device with a single wire for transmitting the data and another
wire for receiving.
When the high-speed data transfer is not required UART is used.
Microprocessor / Microcontroller
Sends and receives data to/from the UART.
Communicates using a parallel data bus and control bus.
76 Bharghavi Y
Sender UART (Transmit section)
Takes parallel data IN from the processor.
Coverts parallel data info serial data. Sends this serial data to the serial connector (TX line).
Receiver UART
Takes serial data from the serial connector (RX line).
Converts serial data into parallel data OUT.
Sends the parallel data back to the processor.
77 Bharghavi Y
3. Control Logic (RX)
Detects start bit, stop bit, parity.
Controls timing and data loading.
Baud Rate Generator
FIFO
If mulitple bytes are written, they are stored in the FIFO.
Helps smooth transmission without losing data.
78 Bharghavi Y
so the transmission frame looks like:
2. Clock sampling
UART samples the incoming line using a clock.
Detects the start bit (0) to begin reading data.
4. FIFO
If multiple bytes arrive, FIFO stores them.
Prevents data loss when CPU is slow to read.
In a simple serial communication, 3 pins are used: TxD, RxD and GND.
At transmission side (i.e. from microcontroller), one can write data into UART Data Register (e.g.
UART0_DR) by using software code.
These 8 bits of data from Data Register is passed to Tx FIFO Buffer. After that, the data is sent out(one
at a time) from Tx Shift Register.
Tx FIFO flag = 1 (Buffer full) TXFIFO flag = 0 (not full – software can write to Data Register).
79 Bharghavi Y
At receiver end, there is RX FIFO Buffer.
RXFIFO Empty flag = 1 (Buffer is Empty) RXFIFO Empty flag = 0 (Buffer has data to be
read).
2. Start Bit
Always 0.
Tells the receiver: “Data is starting now”.
3. Data Bits
Actual data being sent (example: bits 0-7).
Sent LSB first (least significant bit).
5. Stop bit(s)
Always 1. Indicates the end of the data frame.
Gives time for receiver to reset.
80 Bharghavi Y
Frame
Parity
Parity bit is used to check the integrity of a frame and signal if an error occurred during
transmission.
It is an extra bit added to the end of a frame.
Even parity: The number of ‘1’ symbols inside a frame must always be even.
Odd parity: The number of ‘1’ symbols inside a frame must always be odd.
6.10 Configuration
The configuration settings at both ends of Txd and Rxd:
Full or half-duplex operation
Data length
Start/Stop bits
Transmission speed.
81 Bharghavi Y
Real Life Usage
1. Microcontroller communication
Arduino ↔ Sensors/modules
STM32 / ESP32 / PIC communication
Debug consoles during firmware development.
2. Embedded systems
GPS modules
GSM/LTE modules (SIM800, A7680C, Quectel, etc.)
RFID readers
Motor controllers
Industrial controllers
3. Consumer electronics
PC peripherals
Old mice and modems
Set-top boxes (debug UART ports)
4. PC / Server / Router Diagnostics
Routers have hidden UART pins for firmware flashing
Servers/boards expose UART for boot logs
5. Automotive
Communication between ECUs and diagnostic tools
Tuning equipment
6. Robotics
Inter-module communication (motor drivers, IMUs, LiDAR, etc.)
l Main Features of UART
l Asynchronous communication (no shared clock)
l Full-duplex (TX and RX separate)
l Configurable baud rate (9600, 115200, etc.)
l Simple hardware interface (just TX, RX, GND)
l Framing structure: Start bit, Data bits, Parity bit (optional), Stop bit(s)
82 Bharghavi Y
l Supports parity: none, even, odd
l Point-to-point communication only
l Well supported across almost all microcontrollers and CPUs
Applications of UART
1. Embedded device communication
l Sending commands or sensor data
l Remote debugging
l Logging system events
2. Peripheral interfacing
l Connecting modules (Bluetooth HC-05, GPS NEO-6M, LoRa SX1278)
l Motor controllers (e-bike ECUs, servo boards)
3. Industrial
l Factory automation devices
l PLC modules
l Testing equipment
4. Communication bridges
l UART–USB (FTDI, CH340, CP2102)
l UART–SPI or UART–I2C converters
Advantages and Disadvantages
Advantages
Requires minimum wires
No need from clock or any other timing signal.
Parity bit ensures basic error checking.
Disadvantages
Size of the data in the frame is limited.
Can connect only two devices at a time.
Speed for data transfer is less compared to parallel.
Transmitter and receiver must agree to the rules of transmission and appropriate baud rate must
be selected.
83 Bharghavi Y
6.11 Interview Questions
1. What does UART stand for?
2. What is UART and how does it work?
3. What is the difference between UART, SPI and I2C?
4. What is the baud rate in UART communication, and how is it determined?
5. How does the UART transmitter and receiver synchronize the data transmission and reception?
6. What is the biffer in UART, and how does it work?
7. How does flow control work in UART, and what are the different types of flow control?
8. What are the advantages of UART over other communication protocols/
9. Can you explain how errors can occur in UART communication, and how they can be corrected
?
10. What is a UART frame, and what does it consist of ?
11. What is the maximum data rate that can be achieved with UART communication, and how can
it be improved ?
12. What are the different types of UART errors, and how can they be detected and corrected ?
13. What is the role of the UART buffer, and how does it help improve communication reliability ?
14. What are the different UART modes, and how are they used in different applications ?
15. What is the difference between UART and SPI communication ?
16. What is the purpose of the UART baud rate, and how is it configured ?
17. What is flow control, and how is it used in UART communication ?
18. What is the purpose of the UART parity bit, and how does it help detect errors ?
19. What is the role of the UART controller, and how does it interact with other components in a
system?
84 Bharghavi Y
I2C
(INTER INTEGRATED CIRCUIT)
7 Introduction
• I2c stands for inter-integrated circuit. It is a well-known bus invented by Philips Semiconductor
in
• 1982.
• It is a synchronous, multi-master, multi-slave, packet switched, single ended 2-wire bus having
data
• rate of about 100 kbps, 400-450 kbps and 3.4 Mbps.
• It combines the best features of SPIs and UARTs.
• With I2C, we can connect multiple slaves to a single master and can have multiple masters
• controlling single, or multiple slaves.
• This is really useful when you want to have more than one micro-controller logging data to a
single
• memory card or displaying text to a single LCD.
• It is widely used for attaching lower-speed peripheral ICs to processors and micro-controllers in
• short-distance, intra-board communication.
• A particular strength of I2C is the capability of it microcontroller to control a network of device
chip
• with just two general-purpose I/O pins and software.
• Many other bus technologies used in similar applications, such as Serial Peripheral Interface Bus,
• require more pins and signals to connect multiple devices.
7.1 Design
Typical voltages used are +5v or +3.3v, although systems with other voltages are permitted.
85 Bharghavi Y
The I2C bus drivers are “open drain”, meaning that they can pull the corresponding signal line
low, but cannot drive it high.
Thus, there can be no bus contention where one device is trying to drive the line high while
another tries to pull it low, eliminating the potential for damage to the drivers or excessive
power dissipation in the system.
Each signal line has a pull-up resistor on it, to restore the signal to high when no device is
asserting it low.
7.2 Interface
Connections are minimized by using a serial data (SDA) line, a serial clock (SCL) line, and a common
ground to carry all communications.
Master Slave
Fig:
I2C
86 Bharghavi Y
7.3 How I2C works
• With I2C, data is transferred in messages. Messages are broken up into frames of data.
• Each message has an address frame that contains the binary address of the slave, and one or
more data frames that contain the data being transmitted.
• The message also contains start and stop conditions, read/write bits, and ACK/NACK bits
between each data frame.
87 Bharghavi Y
In a combined transactions, each read or write begins with a START and the slave address.
The START condition after the first are also called repeated START bits.
Repeated STARTs are not preceded by STOP conditions, which is how slaves know that the
next message is part of the same transaction.
7.5 Timing Diagram
Data transfer is initiated with a start bit (S) signaled by SDA being pulled low while SCL stays
high.
SCL is pulled low, and SDA sets the first data bit level while keeping SCL low.
The data are sampled (received) when SCL rises for the first bit (B1). For a bit to be valid, SDA
must not change between a rising edge of SCL and the subsequent falling edge.
This process repeats, SDA transitioning while SCL is low, and the data being read while SCL is
high (B2, ...Bn).
A stop bit (P) is signaled when SCL rises, followed by SDA rising.
88 Bharghavi Y
7.7 Which I2C Node Devices Need Clock Stretching?
Whether or not clock stretching is needed depends on the functions of the node device. Here are two
examples:
A processing device, such as a microprocessor or a microcontroller, may need additional time to
process an interrupt, receive and manage data, and perform the appropriate function(s).
A simpler device, such as an EEPROM, does not process data internally, so it does not need
clock stretching to perform any of its functions.
Real-Life Usage
Used inside smartphones, laptops, and microcontrollers to connect chips like sensors, memory,
and displays.
Found in systems like Arduino, Raspberry Pi, and other embedded devices.
Common in temperature sensors, EEPROMs, RTCs (real-time clocks), and LCD displays
89 Bharghavi Y
FEATURES APPLICATIONS
Uses two wires only – SDA (data) and SCL Sensors: temperature, humidity, pressure sensors.
(clock)
Supports multiple masters and slaves on one bus. Displays: LCD or OLED displays
Can communicate at different speeds (Standard: Memory devices: EEPROM, flash storage.
100 kHz, Fast: 400 kHz, etc.).
Each devices has a unique 7-bit or 10-bit address. Real-time clock (RTC): for keeping time.
Supports clock stretching for synchronization. Microcontroller communication: Between chips in
embedded systems.
Works well for short-distance communication. Audio/video systems and industrial equipment
control.
ADVANTAGES DISADVANTAGES
Only two wires needed, saving pins and space. Limited distance — best for communication
within a few meters.
Simple design and easy to implement. Lower speed compared to SPI or UART.
Allows multiple devices on one bus. Complex addressing if many devices share the
same bus
Supports error checking (ACK/NACK bits). Pull-up resistors required on lines.
Flexible – works with different voltages and Not ideal for high-noise environments (since it’s
speeds. open-drain).
90 Bharghavi Y
13. What are some common issues that can arise when using I2C, and how can they be resolved?
14. How does clock stretching work in I2C communication?
15. What is the maximum number of devices that can be connected to an I2C bus?
16. What is the difference between an I2C master and an I2C slave?
17. What is clock stretching and why is it used in I2C communication?
18. What are the reserved address in I2C ?
19. Explain the 10 BIT Addressing mode in I2C?
91 Bharghavi Y