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

Module-6

The document provides an overview of serial interfacing, particularly in ARM processors, highlighting the use of UART and SPI for communication with various devices. It details the RS232 standard, including its electrical characteristics, pin configurations, and the MAX232 IC for interfacing. Additionally, it covers the architecture and registers of UART in the LPC1768 microcontroller, emphasizing its role in serial communication.

Uploaded by

ryu.asahina17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Module-6

The document provides an overview of serial interfacing, particularly in ARM processors, highlighting the use of UART and SPI for communication with various devices. It details the RS232 standard, including its electrical characteristics, pin configurations, and the MAX232 IC for interfacing. Additionally, it covers the architecture and registers of UART in the LPC1768 microcontroller, emphasizing its role in serial communication.

Uploaded by

ryu.asahina17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 60

Module - 6

SERIAL, ADC AND DAC


INTERFACING
General introduction to serial interfacing

Serial interfacing is a communication protocol used to transfer data between two


or more devices in a sequential manner.

In ARM processors, serial interfacing is commonly used to connect


devices such as
• sensors,
• actuators, and
• other peripherals to the processor etc…
Serial interfaces are typically classified into two categories:
1. Synchronous and
2. Asynchronous

Synchronous interfaces require a clock signal to be transmitted along with


the data, while asynchronous interfaces do not.

Asynchronous interfaces are more commonly used in ARM processors, as


they are simpler to implement and require fewer hardware resources.
The most common types of serial interfaces used in ARM processors are
1. UART (Universal Asynchronous Receiver-Transmitter) and
2. SPI (Serial Peripheral Interface).

• UART is a simple serial interface that uses two wires (RX and TX) for
communication.
• SPI, on the other hand, is a more complex interface that can support multiple devices
using a single bus.
To interface with a UART or SPI device, the ARM processor typically uses one of its built-
in hardware modules known as a USART (Universal Synchronous/Asynchronous
Receiver-Transmitter) or SPI controller. These modules provide the necessary hardware
support to generate and receive the serial data, as well as handle other aspects of the
communication protocol such as framing and error detection.
Programming the USART or SPI controller involves configuring various registers in
the ARM processor to set up the communication parameters such as
a. Baud rate,
b. Data format, and
c. Flow control.

Once the controller is configured, the ARM processor can send and
receive data by reading and writing to specific registers associated with
the controller.
RS232 (Recommended Standard 232)
• RS232 (Recommended Standard 232) is a popular serial communication standard that
has been used for decades in many electronic devices.
• The standard defines the electrical and physical characteristics of the communication
protocol, including voltage levels, signal timing, and connector pinouts.
• To implement RS232 in an ARM processor, a UART module is typically used.
• The UART module is responsible for generating and receiving the serial data signals
and for handling other aspects of the communication protocol such as framing and
error detection.
RS232 (Recommended Standard 232)
• The ARM processor provides hardware support for implementing RS232 through one
of its built-in USART (Universal Synchronous/Asynchronous Receiver-Transmitter)
modules.
• The USART module provides a flexible interface that can be configured to operate in
either synchronous or asynchronous mode and supports a range of data formats,
including 8-bit and 9-bit data, as well as parity and stop bits.
• To use the USART module for RS232 communication, the ARM processor must be
configured with the appropriate baud rate, data format, and flow control settings.
• Once configured, the processor can transmit and receive data over the RS232
interface by reading and writing to the appropriate USART registers.
• Rs-232 cable is used to identify the difference between two signal levels between
logic 1 and logic 0.
• The logic 1 is represented by the -12V and logic 0 is represented the +12V.
• The RS-232 cable works at different baud rates like 9600 bits/s, 2400bits/s,
4800bits/s etc.
• The RS-232 cable has two-terminal devices namely Data Terminal Equipment and
Data communication Equipment. Both devices will send and receives signals.
• The data terminal equipment is a computer terminal and data communication
Equipment is modems, or controllers, etc.
• Data Terminal Equipment (DTE) : It includes any
unit that functions either as a source of or as a
destination for binary digital data.
• Data Circuit Terminating Equipment (DCE) : It
includes any functional unit that transmit or receives
data in form of an analog or digital signal through a
network.

• Now a day’s most of the personal computers have two serial ports and
one parallel port (RS232).
• The parallel port sends and receives the 8-bit data at a time over eight
separate wires and this transfers the data very quickly, the parallel
ports are typically used to connect a printer to a PC.
• A serial port sends and receives one-bit data at a time over one wire
and it transfers data very slowly. The RS-232 stands for recommended
slandered and 232 is a number X indicates the latest version like RS-
232c, RS232s.
It is a 25-pin connector, each pin has its function is as PIN9: This pin is a DTE serial connector, this signal follows the incoming ring
to an extent. Normally this signal is used by DCE auto-answer mode.
follows. PIN 10: Test Pin.
PIN 1: (Protective Ground); It is a ground Pin.
PIN 11: standby select.
PIN 2: Transmit Data.
PIN 12: Data Carrier Detect.
PIN 3: Receive Data.
PIN 13: Clear to send.
PIN 2 & PIN 3: These pins are the most important pins for data
PIN 14: Transmit data.
transmitting and receiving. The 1 & 2-pins are used to data transmission
PIN 15: Transmit clock.
and pin-3 used to data receiving purpose.
PIN 17: Receive clock.
PIN 4: Request to send.
PIN 24: External Clock.
Pin 5: Clear to send.
PIN 15, 17, 24; Synchronous modems use the signals on these pins. These pins
PIN 6: Data Set Ready.
are controlled bit timing.
PIN 20: Data terminal Ready.
PIN 16: Receive data.
PIN 4, PIN 5, PIN 6, PIN 20: These pins are the handshaking pins(flow
PIN 18: Test Pin.
of control). Normally terminals cannot transmit the data until clear to send
PIN 19: Request to send.
transmission is received from the DCE.
PIN 21: (Signal Quality Detector); This pin Indicates the quality of the
PIN 7: This pin is the common reference for all signals, including data,
received carrier signal because the transmitting modem must be sent 0 or either
timing, and control signals. The DCE and DTE work properly across the
1 at each bit time, the modem controls the timing of the bits from the DTE.
serial interface and the pin-7 must be connected both ends without
PIN 22: (Ring Indicator): The ringing indicator means the DCE informs the
interface would not work.
DTE that the phone is ringing. All the modems designed for directly connected
PIN 8: This pin is also known as received line signal detector carrier
to the phone network equipped with the auto-answer.
detect. This signal is activated when a suitable carrier is established
PIN 23: Data Signal Rate Detector
between the local and remote DCE devices.
RS232 (Recommended Standard 232)
The LPC 1768 micro-controller consists of 4 UART
peripherals. (UART0, UART1, UART2, and
UART3). Few of the striking features of these
peripherals are:
• Like any other UART peripheral, they can handle data sizes
of 5 to 8 bits.
• They support 16 bytes receive and transmit FIFOs. Which
means that they can store 16-bytes of data in a first in first
out fashion without overwriting existing data in the FIFO
buffer before it gets filled.
• It has a built-in baud rate generator.
• It supports built-in DMA (Direct Memory Access) for
transmission and reception which is ideal when data of byte
size has to be transmitted and the controller has to be
relieved from basic data communication to perform other
tasks.
• It has multi-processor addressing modes and has an IrDA
mode to support infrared communication as well.
MAX232
• MAX232 is a popular RS232 driver and receiver IC that is often used in embedded
systems to interface with RS232 devices.
• The MAX232 IC is designed to convert the TTL-level (Transistor-Transistor Logic)
signals from an ARM processor's UART module to the RS232 voltage levels needed to
communicate with a serial device.
• The MAX232 IC typically operates from a single 5V power supply and has four
voltage level converter channels, which can convert the TTL-level signals from the
ARM processor's UART module to the higher voltage levels used by RS232 devices.
• The IC also includes capacitors to generate the required charge pumps for the voltage
conversion.
• To interface an ARM processor with an RS232 device using the MAX232 IC, the
UART module of the processor is typically connected to the input pins of the MAX232
IC. The MAX232 IC's output pins are then connected to the RS232 device's input and
output pins, respectively.
• Pin-1(C1+): The positive terminal of a capacitor is connected to this pin
• Pin-2(Vs+): The capacitor’s positive leg is connected to it by grounding the negative leg.
• Pin-3(C1-): The negative pin of the capacitor is connected to this pin and the positive pin is connected to pin1
• Pin-4(C2+): The positive terminal of a capacitor is connected to this pin
• Pin-5(C2-): The negative terminal of a capacitor is connected where the positive terminal is connected to Pin4.
• Pin-6(Vs-): The negative terminal of a capacitor is connected to this pin & 5 volts is provided to the positive terminal of the
capacitor.
• Pin-7(T2OUT): It provides the converted TTL signal in the form of RS-232. Here TTL signal can be obtained by T2IN Pin
from the microcontroller and this pin is connected to Pin2 of DB-9 port of your computer like Rxd.
• Pin-8(R2IN): This Pin gets the signal of RS-232 like an input & provides the changed signal in the form of TTL on the
R2OUT pin. This pin is connected to DB9 Port’s Txd pin, which is Pin3.
• Pin-9(R2OUT): It provides the signal changed within TTL form. The signal is received from Pc at R1In Pin. Connect this
pin to your module (TTL) Rxd pin which receives the signal.
• Pin-10(T2IN): This pin gets transmitted signal from microcontroller & gives the changed RS-232 signal over T2OUT pin.
Here, the signal can be transmitted from the microcontroller serial port’s txd pin. This pin can be connected to your Txd pin
of the module.
• Pin-11(T1IN): This pin works like a T2IN.
• Pin-12(R1OUT): This pin works like an R2OUT.
• Pin-13(R1IN): This pin works like an R2IN.
• Pin-14(T1OUT): This pin works like aT2OUT.
• Pin-15(GND): This pin is a GND pin.
• Pin-16(VCC): This pin is a voltage supply pin where 5V is provided to this pin.
Applications of MAX232

• It is used to interface microcontroller through PC


• Computers
• Used to convert from TTL or CMOS logic to RS232
• Modem.
• Terminals
• Utilized within RS232 cables
• Portable Computing
• Transactions of Interface
• RS232 System Powered with a Battery
• Fewer Power Modes
UART
• UART is used for Serial Communication and is one of the commonly used
peripherals in LPC1768 MCU, mostly for communicating a computer for
transmitting debug messages, receiving commands etc.
• UART is short for Universal Asynchronous Receiver / Transmitter. It is a type of
serial communication usually between a Microcontroller and a Computer. UART is
a full-duplex communication and hence it needs two wires/lines between the
communicating devices. They are called as TX and RX.

The ‘A’ in UART stands for Asynchronous. What this means is that there is no clock
signal between the communicating devices (in contrast to I2C and SPI, which are also
Serial Communications but use a clock signal to synchronize data).
In UART, the data is transmitted in the form of ‘packets’ or ‘frames’. The structure of
a typical UART data packet is shown below.

• At the beginning of a frame, there is START Bit, which is a ‘0’ and it indicates the
receiver about the data about to be transmitted.
• The START Bit is followed by the actual data to be transmitted. Its length can be
anywhere between 5-bits and 8-bits. After the data, there is a parity bit, which can be
used for error checking. This bit is optional.
• Finally, to signify the end of current data transfer, there are STOP Bits, which is
usually ‘1’ of length 1 or 2 bits wide. To transmit the next set of data, repeat the
process.
UART in LPC1768
Coming to UART in LPC1768 MCU, it consists of four UART peripherals viz.
• UART0
• UART1
• UART2
• UART3

UART0, UART2 and UART3 are identical with basic UART functionality, while
UART1 adds full modem control handshaking support.

UART1 also supports RS-485/RS-232. The UART0 is used for in-system


programming. Both UART0 and UART1 are enabled after reset.
Pins Associated with UART
Architecture of UART in LPC1768

• In case of data transmission, the data to


be transmitted is written into the THR
Register. This data is then buffered into
the TX FIFO.
• A shift register then reads the data from
the buffer and transmits is via the
corresponding TXD Pin.
• Coming to receiving data, a valid data is
captured by the shift register in the
receiver block and is transmitted to the
RX FIFO.
• Finally, the data is held in the RBR
register for the processor to access it.
LPC1768 UART Registers
• UART0, UART2 and UART3 have 14 NOTE: Use the nomenclature from the reference
registers each for UART Data, Interrupt, manual for UART Registers. For example, when I
Status and Control. say UxRBR, it represents the Receiver Buffer
• UART1 has a total of 18 registers. Some of Register of either UART0, UART2 or UART3 i.e.
the important registers of UART0/2/3. x = 0 or 2 or 3.
• UxFCR – FIFO Control Register: Controls the UARTx RX and UARTx TX FIFO operations.
• UxLCR – Line Control Register: Determines the data format used in transmission.
• UxLSR – Line Status Register: Provides the status of RX and TX blocks.
• Bits 1 to 4 get cleared after reading UxLSR.
• UxTER – Transmit Enable Register: Used to enable UART transmission. When TXEN (Bit 7) is set to 1, the TX block will keep
on transmitting data as long as it is available. If TXEN is set to 0, then transmission will stop.
• UxRBR – Receiver Buffer Register: This register contains the top byte of the RX FIFO i.e the oldest character received data in
FIFO. Before reading from UxRBR, the DLAB (Divisor Latch Access) bit in UxLCR register must be 0.
• UxTHR – Transmit Holding Register: UxTHR contains the top byte in TX FIFO. It is the newest character in the TX FIFO. The
DLAB in UxLCR must be 0 in order to access UxTHR.
• UxDLL and UxDLM – Divisor Latch Registers (LSB and MSB): These registers are a part of baud rate generator. Together, they
contain the 16-bit divisor value for the APB Clock to generate the desired baud rate. UxDLL contains the lower 8-bits of the divisor
while UxDLM contains the higher 8-bits. Before accessing these registers, the DLAB bit in UxLCR must be 1.
• UxFDR – Fractional Divider Register: It controls the clock pre-scalar value for baud rate generation. The APB Clock is divided
into a desired clock based of the divider and multiplier values in this register.
Data Acquisition System
• Data acquisition is the process of sampling signals that measure real-world physical
conditions and converting the resulting samples into digital numeric values that can be
manipulated by a computer.
• Data acquisition systems, abbreviated by the acronyms DAS, DAQ, or DAU, typically
convert analog waveforms into digital values for processing.

The components of data acquisition systems include:

• Sensors, to convert physical parameters to electrical signals.

• Signal conditioning circuitry, to convert sensor signals into a form that can be converted
to digital values.

• Analog-to-digital converters, to convert conditioned sensor signals to digital values.


Data Acquisition System (Contd.)

• Data acquisition applications are usually controlled by software programs developed


using various general purpose programming languages such as Assembly, BASIC, C,
C++, C#, Fortran, Java, LabVIEW, Lisp, Pascal, etc.
• Stand-alone data acquisition systems are often called data loggers.
• There are also open-source software packages providing all the necessary tools to
acquire data from different, typically specific, hardware equipment.
• These tools come from the scientific community where complex experiment requires
fast, flexible, and adaptable software.
• Those packages are usually custom-fit but more general DAQ packages like the
Maximum Integrated Data Acquisition System can be easily tailored and are used in
several physics experiments.
Sources and systems- Digital Data Acquisition Systems
• Data acquisition begins with the physical phenomenon or physical property to be measured. Examples of this
include temperature, vibration, light intensity, gas pressure, fluid flow, and force. Regardless of the type of
physical property to be measured, the physical state that is to be measured must first be transformed into a
unified form that can be sampled by a data acquisition system. The task of performing such transformations
falls on devices called sensors.
• A data acquisition system is a collection of software and hardware that allows one to measure or control the
physical characteristics of something in the real world. A complete data acquisition system consists of DAQ
hardware, sensors and actuators, signal conditioning hardware, and a computer running DAQ software. If
timing is necessary (such as for event mode DAQ systems), a separate compensated distributed timing
system is required.
• A sensor, which is a type of transducer, is a device that converts a physical property into a corresponding
electrical signal (e.g., strain gauge, thermistor). An acquisition system to measure different properties
depends on the sensors that are suited to detect those properties. Signal conditioning may be necessary if the
signal from the transducer is not suitable for the DAQ hardware being used.
• The signal may need to be filtered, shaped, or amplified in most cases. Various other examples of signal
conditioning might be bridge completion, providing current or voltage excitation to the sensor, isolation, and
linearization. For transmission purposes, single ended analog signals, which are more susceptible to noise
can be converted to differential signals. Once digitized, the signal can be encoded to reduce and correct
transmission errors.
DAQ hardware
• DAQ hardware is what usually interfaces between the signal and a PC. It could be in the
form of modules that can be connected to the computer's ports (parallel, serial, USB, etc.)
or cards connected to slots (S-100 bus, AppleBus, ISA, MCA, PCI, PCI-E, etc.) in a PC
motherboard or in a modular crate (CAMAC, NIM, VME). Sometimes adapters are
needed, in which case an external breakout box can be used.
• DAQ cards often contain multiple components (multiplexer, ADC, DAC, TTL-IO, high-
speed timers, RAM). These are accessible via a bus by a microcontroller, which can run
small programs. A controller is more flexible than a hard-wired logic, yet cheaper than a
CPU so it is permissible to block it with simple polling loops. For example: Waiting for a
trigger, starting the ADC, looking up the time, waiting for the ADC to finish, move value
to RAM, switch multiplexer, get TTL input, let DAC proceed with voltage ramp.
• Today, signals from some sensors and Data Acquisition Systems can be streamed via
Bluetooth.
DAQ device drivers
DAQ device drivers are needed for the DAQ hardware to work with a PC. The
device driver performs low-level register writes and reads on the hardware while
exposing API for developing user applications in a variety of programs.

Input devices
• 3D scanner
• Analog-to-digital converter
• Time-to-digital converter
• Hardware
• Computer Automated Measurement and Control (CAMAC)
• Industrial Ethernet
• Industrial USB
• LAN eXtensions for Instrumentation
• Network interface controller
• PCI eXtensions for Instrumentation
• VMEbus
• VXI

DAQ software
Specialized DAQ software may be delivered with the DAQ hardware. Software tools
used for building large-scale data acquisition systems include EPICS. Other
programming environments that are used to build DAQ applications include ladder
logic, Visual C++, Visual Basic, LabVIEW, and MATLAB.
LPC1768 ADC Registers
LPC1768 ADC Modes

Software controlled mode :

• In Software mode only one conversion will be done at a time. To perform another conversion you will need to re-
initiate the process.
• In software mode, only 1 bit in the SEL field of ADCR can be 1 i.e. only 1 Channel(i.e. Pin) can be selected for
conversion at a time. Hence conversions can be done only any channel but one at a time.

Hardware or Burst mode :

• In Hardware or Burst mode, conversions are performed continuously on the selected channels in round-robin
fashion. Since the conversions cannot be controlled by software, Overrun may occur in this mode.
• Overrun is the case when a previous conversion result is replaced by new conversion result without previous result
being read i.e. the conversion is lost. Usually an interrupt is used in Burst mode to get the latest conversion
results. This interrupt is triggered when conversion in one of the selected channel ends.
Analog to Digital Convertor Program
DAC Programming

You might also like