0% found this document useful (0 votes)
15 views

Module 4 - Asynchronous and Synchronous Serial Communications, Periodic Interrupts, Waveform Generation, Time Measurement (New)

Uploaded by

Rodger Uche
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Module 4 - Asynchronous and Synchronous Serial Communications, Periodic Interrupts, Waveform Generation, Time Measurement (New)

Uploaded by

Rodger Uche
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 48

Asynchronous and Synchronous

Serial Communications,
Periodic Interrupts, Waveform
Generation, Time Measurement
CPE112: Embedded Systems
Serial Communication

❑ Serial Transfer
❑ serial communication is the process of sending/receiving data in one bit
at a time
Parallel Communication
❑ Parallel Transfer
❑ Parallel communication is the
process of sending/receiving
multiple data bits at a time
through parallel channels.
Serial vs Parallel Communication

Serial Communication Parallel Communication

1. One data bit is 1. Multiple data bits are


transceived at a time
transceived at a time
2. Slower 2. Faster

3. Less number of cables 3. Higher number of


cables required
required to transmit data
Modes of Connection
❑ One-way: data sent in one direction only.
❑ Half-Duplex: two-way transfer, but only in one direction at a time.
❑ Full-duplex: send and receive data simultaneously.

❑ RS232 and SPI are full-duplex.


❑ I2C or I2C is half-duplex
Synchronous,
Asynchronous and
Iso-Synchronous Communication
Synchronous
❑ In Synchronous data transfer, each basic unit of data (such as a bit) is
transferred in accordance to a clock COMMUNICATION signal or in other words
the data is transferred at a pre-decided rate. So for this data transfer method a
clock signal is needed. Moreover Synchronous data transfer systems usually
have an error checking mechanism to guarantee data integrity over
transmission.
Asynchronous
❑ In Asynchronous data transfer systems, the data can be sent at irregular
intervals and there is no pre-decided data rate of transmission. Special bits such
as Start and stop bits are reserved to detect the start and end of data
transmission in these systems and they are also equipped with an error
checking mechanism.
Isochronous
❑ Isochronous data transfer lies somewhat in between the two other data transmission types. It
sends Asynchronous data over a Synchronous transmission system. In such systems each data
source is given only a fixed time to transmit its data. In that fixed interval of time, that data
source can transfer data at whatever intervals it wants. If it has data which requires less time
than the time allotted then it simply wastes the extra time by staying idle. Otherwise if it has
data which requires more time to transmit than given then it sends the remaining data in its
next turn. These systems do not have error check mechanism because it is not possible to re-
transmit the data after an error due to strict timing conditions.
❑ Synchronous, asynchronous, and isochronous transmission are not three of a
kind but two unrelated pairs, where the asynchronous transmission that differs
from synchronous transmission may not be the same as the asynchronous
transmission that differs from isochronous transmission. Of course, both pairs
are about timing.

❑ RS-232 and USB are asynchronous


❑ SPI and I2C are syncrhonous
Serial Data Transfer Protocol
Serial Data Transfer Protocol
❑ The line is initially HIGH (No Transmission).
❑ To start communication, the transmitter (Tx) pull the line low for 1
bit interval called the start bit.
❑ A number of data bits (e.g. 8-bits) are then sent in ASCII format.
❑ The Tx then send 1 bit HIGH (stop bit) to retain the original state of
the line.
❑ After sending the character, an interrupt is issued to the processor.
❑ Thus, each transmitted character is packaged in a character frame.
Character Frame consists of:
❑ Start bit: the bit which signals the receiver that data is coming.
❑ Data bits: amount of actual data in a packet (5 ,7 or 8 bits).
❑ Parity: its’s used for error checking in serial communication. There
are two types of parity: even and odd. The option of no parity is also
available.
❑ Stop bit: is used to indicate the end of a single packet. Typical values
are 1, 1.5 and 2 bits. The stop bits not only indicate the end of the
transmission but also give the computers some room for error in the
clock speeds.
Tx and RX must agree on:
1. The transmission rate (bit rate)
▪ By adjusting the same bit rate in both transmitter and receiver, they can
adjust the time of each bit and get the data correctly.
2. The number of data bits encoding a character
3. The optional parity bit
4. The number of stop bits
Serial Communication Protocols
1. Serial Peripheral Interface (SPI) : It is a three-wire based communication system.
One wire each for master to slave, and Vice-versa, and one for clock pulses. There is
an additional SS (Slave Select) line, which is mostly used when we want to
send/receive data between multiple ICs.
2. Inter-Integrated Circuit (I2C) : Pronounced eye-two-see or eye-square-see, this is an
advanced form of USART. The transmission speeds can be as high as a whopping
400KHz. The I2C bus has two wires – one for clock, and the other is the
data line, which is bi-directional – this being the reason it is also
sometimes (not always – there are a few conditions) called Two Wire
Interface (TWI). It is a pretty new and revolutionary technology invented
by Philips.
Serial Communication Protocols
3. FireWire – Developed by Apple, they are high-speed buses capable of audio/video
transmission. The bus contains a number of wires depending upon the port, which can be
either a4-pin one, or a 6-pin one, or an 8-pin one.
Serial Communication Protocols
4. Ethernet: Used mostly in LAN connections, the bus consists of 8 lines, or 4
Tx/Rx pairs.

5. Universal serial bus (USB): This is the most popular of all. Is used for
virtually all type of connections. The bus has 4 lines: VCC, Ground, Data+, and
Data-.
Serial Communication Protocols
6. Recommended Standard 232 (RS-232) : The RS-232 is typically connected
using a DB9 connector, which has 9 pins, out of which 5 are input, 3 are
output, and one is Ground. You can still find this so-called “Serial” port in
some old PCs. In our upcoming posts, we will discuss mainly about RS232 and
USART of AVR microcontrollers.
Timers and Counters
Timers/Counters are used generally for:
1. Time reference
2. Creating delay
3. Wave form properties measurement
4. Periodic interrupt generation
5. Waveform generation
Interrupts
Interrupt
❑ a signal which has highest priority from hardware or software which
processor should process its signal immediately.
Interrupt
❑ Polling method
▪ In early years of computing processor has to wait for the signal for processing,
so processor has to check each and every hardware and software program in
the system if it has any signal to process. In this method the problem
processor has to waste number of clock cycles just for checking the signal in
the system, by this processor will become busy unnecessarily. If any signal
came for the process, processor will take some time to process the signal due
to the polling process in action. So system performance also will be degraded
and response time of the system will also decrease.
Interrupt
❑ Interrupt-driven method
▪ It will not check for any signal from hardware or software but instead
hardware/software will only send the signal to the processor for processing.
The signal from hardware or software should have highest priority because
processor should leave the current process and process the signal of
hardware or software.
Types of Interrupts
1. Hardware Interrupts: If the signal for the processor is from external
device or hardware is called hardware interrupts. Example: from
keyboard we will press the key to do some action this pressing of
key in keyboard will generate a signal which is given to the
processor to do action, such interrupts are called hardware
interrupts.
▪ Hardware interrupts can be classified into two types they are
▪ Maskable Interrupt: The hardware interrupts which can be delayed when a much
highest priority interrupt has occurred to the processor.
▪ Non Maskable Interrupt: The hardware which cannot be delayed and should process by
the processor immediately
Types of Interrupts
2. Software Interrupts:
▪ Software interrupts can be classified into two types they are
▪ Normal Interrupts: the interrupts which are caused by the software instructions are
called software instructions.
▪ Exception: unplanned interrupts while executing a program is called Exception. For
example: while executing a program if we got a value which should be divided by zero is
called a exception.
Classification of Interrupts According to
Periodicity of Occurrence
1. Periodic Interrupt: If the interrupts occurred at fixed interval in
timeline then that interrupts are called periodic interrupts
▪ useful for real-time clocks, data acquisition systems, and control systems

2. Aperiodic Interrupt: If the occurrence of interrupt cannot be


predicted then that interrupt is called aperiodic interrupt.
Classification of Interrupts According to the
Temporal Relationship with System Clock
1. Synchronous Interrupt: The source of interrupt is in phase to the
system clock is called synchronous interrupt. In other words
interrupts which are dependent on the system clock. Example:
timer service that uses the system clock.
2. Asynchronous Interrupts: If the interrupts are independent or not
in phase to the system clock is called asynchronous interrupt
Waveform/Signal Generation
Signal Generator
❑ generator of signals used as a stimulus for electronic measurements
❑ Most circuits require some type of input signal whose amplitude
varies over time.
❑ provide “ideal” waveforms or it may add known, repeatable
amounts and types of distortion (or errors) to the signal it delivers
❑ acts as testing andmeasurement device for quality improvement
and troubleshooting problem
Analog or Digital?
❑ Arbitrary waveform generators (AWG) and function generators are
aimed primarily at analog and mixed-signal applications.
❑ Digital waveform generators (logic sources) encompass two classes
of instruments.
▪ Pulse generators drive a stream of square waves or pulses from a small
number of outputs, usually at very high frequencies. These tools are most
commonly used to exercise high-speed digital equipment.
▪ Pattern generators/data generators/data timing generators, typically
provide 8, 16, or even more synchronized digital pulse streams as a stimulus
signal for computer buses, digital telecom elements, and more.
Signal Generation Techniques
Modern high-performance signal generators offer at least three ways to
develop waveforms:

❑ Create: Brand new signals for circuit stimulus and testing


❑ Replicate: Synthesize an unavailable real-world signal (captured
from an oscilloscope or logic analyzer)
❑ Generate: Ideal or stressed reference signals for industry standards
with specific tolerances
Waveform Properties
❑ Amplitude: A measure of the voltage “strength” of the waveform.
Amplitude is constantly changing in an AC signal. Signal generators
allow you to set a voltage range, for example, —3 to +3 volts. This
will produce a signal that fluctuates between the two voltage
values, with the rate of change dependent upon both the wave
shape and the frequency.
Waveform Properties
❑ Frequency: The rate at which full waveform cycles occur. Frequency
is measured in Hertz (Hz), formerly known as cycles per second.
Frequency is inversely related to the period (or wavelength) of the
waveform, which is a measure of the distance between two similar
peaks on adjacent waves. Higher frequencies have shorter periods.
❑ Phase: In theory, the placement of a waveform cycle relative to a 0
degree point. In practice, phase is the time placement of a cycle
relative to a reference waveform or point in time.
Terminology
❑ Phase shift: describes the difference in timing between two
otherwise similar signals
❑ Edge transition times (rise and fall times) are characteristics usually
ascribed to pulses and square waves.
❑ Pulse width is the time that elapses between the leading and
trailing edges of a pulse.
❑ Duty cycle is used to describe a pulse’s high and low (on/off) time
intervals.
Basic Waves
❑ Sine waves
❑ Square and
rectangular waves
❑ Sawtooth and triangle
waves
❑ Step and pulse shapes
❑ Complex waves
Types of Analog and Mixed Signal Generators

❑ Arbitrary generators can be classified into


1. Arbitrary/Function Generator (AFG)
▪ serves a wide range of stimulus needs;
▪ offers fewer waveform variations than its AWG equivalent, but with excellent
stability and fast response to frequency changes
▪ low cost, which makes it very attractive for applications that do not require an
AWG’s versatility
▪ it produces stable waveforms in standard shapes (all-important sine and
square waves) – that are both accurate and agile.
Types of Analog and Mixed Signal Generators

2. Arbitrary Waveform Generator (AWG)


▪ sophisticated playback system that delivers waveforms based on stored digital
data that describes the constantly changing voltage levels of an AC signal
▪ it is much like a CD player that reads out stored data (in the AWG, its own
waveform memory; in the CD player, the disc itself) in real time. Both put out
an analog signal, or waveform
▪ offers a degree of versatility that few instruments can match
▪ embraces applications ranging from automotive anti-lock brake system
simulation to wireless network stress testing
Time Measurements In Analog
❑ a quasi-digital signal is defined as a binary signal carrying analog
information in its variations in time
❑ analog information is in the “horizontal” direction (time) rather than
in the vertical direction (voltage)
❑ analog information is either in the distance between two positive
(or negative) edges (= the period or frequency), the distance
between a positive (negative) and a negative (positive) edge (= the
pulse width) or it is in the quotient between the pulse width and the
period (= the duty cycle)
Time Measurements In Digital
❑ A digital time-measuring system is commonly referred to as a Time-
to-Digital Converter (TDC).
❑ a TDC quantize the time between a start and a stop signal and they
are either analog or counter based

Digital TDC
Time Measurements In Digital
❑ However, increasing the clock frequency raises two other issues;
first of all the power consumption increases and secondly, there is a
limit to the maximum oscillator frequency that can be implemented
in CMOS technology (Henzler, 2010).
❑ Vernier time measurements - improve the resolution by
interpolating in between the clock cycle pulses (without increasing
the clock frequency)
▪ Pierre Vernier (1580-1637), inventor of the metric caliper, perform a
mechanical interpolation between the millimeter markers of a ruler.
Time Measurements In Digital
❑ Vernier time measurements can be implemented in several different
ways, both in hardware and in software.
❑ In fact, according to Henzel (2010), the engine that performs this
subdivision of the reference clock cycles is what distinguishes a TDC
from a counter; the counter only provides the “coarse” quantization
value while the TDC provides the interpolated “fine-structure”.
Time measurement in embedded controllers
❑ The second generation time measurement units in microcontrollers
included an Input Capture feature, where the content of a running
timer is automatically latched into a “capture” register at the
occurrence of an external “event”. This is a great help in time
measurements since external events are automatically time
stamped by hardware.

Input Capture
Time measurement in embedded controllers
❑ Charge Time Measurement Unit (CTMU) – Microchip’s next
generation of embedded time measurement units
▪ consists first of all of a very accurate current source and it is used with an
internal ADC to measure either capacitance or time
Uncertainties in basic counting Time-to-
Digital Converter (TDC)
1. Quantization error
2. Trigger error
3. Time-base error
4. Systematic error
Uncertainties in microcontroller-based
Time-to-Digital Converter (TDC)
❑ In microcontroller-based TDCs, the quantization is not necessarily
limited to the ±1 count inherently found in counter-based TDCs; it
depends on the firmware algorithm and also on the hardware
resources used.
❑ For microcontrollers, internally generated threshold noise is rarely
specified in the data sheet.
Microcontroller-implementation of vernier TDC

Microcontroller TDC with vernier


resolution

❑ The microcontroller’s interrupt reaction time can be minimized if the


microcontroller is waiting for interrupt in idle mode (Reverter and Pallàs-Areny,
2006)
❑ A typical microcontroller cannot compare two running timer registers in
hardware and hence the moment of coincidence has to be detected in
firmware,
Thank you for listening.
References
❑ https://www.tek.com/signal-generator
❑ T.VINAYSIMHA REDDY.
❑ Lars E. Bengtsson.Embedded Measurement Systems. Department Of
Physics. University Of Gothenburg.Gothenburg, Sweden 2013
❑ https://users.ece.utexas.edu/~valvano/Volume1/E-
Book/C12_Interrupts.htm

You might also like