Module-6
Module-6
• 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
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.
• Signal conditioning circuitry, to convert sensor signals into a form that can be converted
to digital values.
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
• 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.
• 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