Professional Documents
Culture Documents
Core Architecture
- Full-Speed USB 2.0 Device
- Very Fast On-Chip Flash Up to 512KB
- Up to 40KB SRAM
- 45 Fast I/O Pins with Up to 15MHz Switching
- Vectored Interrupt Controller (VIC)
- 3.3V / 60MHz Operation
- In-System Programming (ISP) via on-chip boot
loader software
- Two 10-bit ADCs provide a total of 14 analog
inputs
- Single 10-bit DAC provides variable analog
output
- Multiple serial interfaces - Two UARTs, Two
Fast I
2
C-bus (400 Kbit/s), SPI and SSP
Fig. 5.2: LPC2148 Block Diagram
5
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 26
Pin Description:
Symbol Pin Description
P0.21/PWM5/
AD1.6/CAP1.3
1
P0.21 General-purpose input/output digital pin (GPIO)
PWM5 Pulse Width Modulator output 5
AD1.6 ADC 1, input 6
CAP1.3 Capture input for Timer 1, channel 3
P0.22/AD1.7/
CAP0.0/MAT0. 0
2
P0.22 General-purpose input/output digital pin (GPIO)
AD1.7 ADC 1, input 7
CAP0.0 Capture input for Timer 0, channel 0
MAT0.0 Match output for Timer 0, channel 0
3 Input to the RTC oscillator circuit
Fig. 5.3: LPC2148 IC Pin Layout
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 27
RTXC1
P1.19/
TRACEPKT3
4
P1.19 General-purpose input/output digital pin (GPIO)
TRACEPKT3 Trace Packet, bit 3. Standard I/O port with
internal pull-up
RTXC2
5
Output from the RTC oscillator circuit
VSS
6
Ground: 0 V reference
VDDA
7
Analog 3.3 V power supply: This should be nominally the
same voltage as VDD but should be isolated to minimize
noise and error. This voltage is only used to power the on-
chip ADC(s) and DAC
P1.18/
TRACEPKT2
8
P1.18 General-purpose input/output digital pin (GPIO).
TRACEPKT2 Trace Packet, bit 2. Standard I/O port with
internal pull-up.
P0.25/AD0.4/
AOUT
9
P0.25 Genera-purpose input/output digital pin (GPIO)
AD0.4 ADC 0, input 4
AOUT DAC output
D+ 10 SB bi-directional D+ line
D- 11 USB bi-directional D- line
P1.17/
TRACEPKT1
12
P1.17 General-purpose input/output digital pin (GPIO)
TRACEPKT1 Trace Packet, bit 1. Standard I/O port with
internal pull-up
P0.28/AD0.1/
CAP0.2/MAT0.2
13
P0.28 General-purpose input/output digital pin (GPIO)
AD0.1 ADC 0, input 1
CAP0.2 Capture input for Timer 0, channel 2
MAT0.2 Match output for Timer 0, channel 2
P0.29/AD0.2/
CAP0.3/MAT0.3
14
P0.29 Genera-purpose input/output digital pin (GPIO)
AD0.2 ADC 0, input 2
CAP0.3 Capture input for Timer 0, Channel 3
MAT0.3 Match output for Timer 0, channel 3
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 28
P0.30/AD0.3/
EINT3/CAP0.0
15
P0.30 General-purpose input/output digital pin (GPIO)
AD0.3 ADC 0, input 3
EINT3 External interrupt 3 input
CAP0.0 Capture input for Timer 0, channel 0
P1.16/
TRACEPKT0
16
P1.16 General-purpose input/output digital pin (GPIO)
TRACEPKT0 Trace Packet, bit 0. Standard I/O port with
internal pull-up
P0.31/UP_LED/
CONNECT
17
P0.31 General-purpose output only digital pin (GPO)
UP_LED USB GoodLink LED indicator. It is LOW when
device is configured (non-control endpoints enabled). It is
HIGH when the device is not configured or during global
suspend
CONNECT Signal used to switch an external 1.5 k
SoftConnect USB feature. Important: This is a digital output
only pin. This pin MUST NOT be externally pulled LOW
when RESET pin is LOW or the JTAG port will be disabled.
VSS
18
Ground: 0 V reference.
P0.0/TXD0/
PWM1
19
P0.0 General-purpose input/output digital pin (GPIO)
TXD0 Transmitter output for UART0
PWM1 Pulse Width Modulator output 1
P1.31/TRST
20
P1.31 General-purpose input/output digital pin (GPIO)
TRST Test Reset for JTAG interface
P0.1/RXD0/
PWM3/EINT0
21
P0.1 General-purpose input/output digital pin (GPIO)
RXD0 Receiver input for UART0
PWM3 Pulse Width Modulator output 3
EINT0 External interrupt 0 input
P0.2/SCL0/
CAP0.0
22
P0.2 General-purpose input/output digital pin (GPIO)
SCL0 I2C0 clock input/output. Open-drain output (for I
2
C-
bus compliance)
CAP0.0 Capture input for Timer 0, channel 0
VDD
23
3.3 V power supply: This is the power supply voltage for the
core and I/O ports.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 29
P1.26/RTCK
24
P1.26 General-purpose input/output digital pin (GPIO)
RTCK Returned Test Clock output. Extra signal added to
the JTAG port Assists debugger synchronization when
processor frequency varies. Bi-directional pin with internal
pull-up
Note: LOW on RTCK while RESET is LOW enables pins
P1.31:26 to operate as Debug port after reset.
VSS
25
Ground: 0 V reference.
P0.3/SDA0/
MAT0.0/EINT1
26
P0.3 General-purpose input/output digital pin (GPIO)
SDA0 I
2
C0 data input/output. Open-drain output (for I
2
C-
bus compliance)
MAT0.0 Match output for Timer 0, channel 0
EINT1 External interrupt 1 input
P0.4/SCK0/
CAP0.1/AD0.6
27
P0.4 General-purpose input/output digital pin (GPIO)
SCK0 Serial clock for SPI0. SPI clock output from master
or input to slave
CAP0.1 Capture input for Timer 0, channel 0
AD0.6 ADC 0, input 6
P1.25/EXTIN0
28
P1.25 General-purpose input/output digital pin (GPIO)
EXTIN0 External Trigger Input. Standard I/O with internal
pull-up
P0.5/MISO0/
MAT0.1/AD0.7
29
P0.5 General-purpose input/output digital pin (GPIO)
MISO0 Master In Slave OUT for SPI0. Data input to SPI
master or data output from SPI slave
MAT0.1 Match output for Timer 0, channel 1
AD0.7 ADC 0, input 7
P0.6/MOSI0/
CAP0.2/AD1.0
30
P0.6 General-purpose input/output digital pin (GPIO)
MOSI0 Master Out Slave In for SPI0. Data output from
SPI master or data input to SPI slave
CAP0.2 Capture input for Timer 0, channel 2
AD1.0 ADC 1, input 0
P0.7/SSEL0/
PWM2/EINT2
31
P0.7 General-purpose input/output digital pin (GPIO)
SSEL0 Slave Select for SPI0. Selects the SPI interface
as a slave
PWM2 Pulse Width Modulator output 2
EINT2 External interrupt 2 input
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 30
P1.24/
TRACECLK
32
P1.24 General-purpose input/output digital pin (GPIO)
TRACECLK Trace Clock. Standard I/O port with internal
pull-up
P0.8/TXD1/
PWM4/AD1.1
33
P0.8 General-purpose input/output digital pin (GPIO)
TXD1 Transmitter output for UART1
PWM4 Pulse Width Modulator output 4
AD1.1 ADC 1, input 1
P0.9/RXD1/
PWM6/EINT3
34
P0.9 General-purpose input/output digital pin (GPIO)
RXD1 Receiver input for UART1
PWM6 Pulse Width Modulator output 6
EINT3 External interrupt 3 input
P0.10/RTS1/
CAP1.0/AD1.2
35
P0.10 General purpose input/output digital pin (GPIO)
RTS1 Request to Send output for UART1
CAP1.0 Capture input for Timer 1, channel 0
AD1.2 ADC 1, input 2
P1.23/
PIPESTAT2
36
P1.23 General-purpose input/output digital pin (GPIO)
PIPESTAT2 Pipeline Status, bit 2. Standard I/O port with
internal pull-up
P0.11/CTS1/
CAP1.1/SCL1
37
P0.11 General-purpose input/output digital pin (GPIO)
CTS1 Clear to Send input for UART1
CAP1.1 Capture input for Timer 1, channel 1
SCL1 I
2
C1 clock input/output. Open-drain output (for I
2
C-
bus compliance)
P0.12/DSR1/
MAT1.0/AD1.3
38
P0.12 General-purpose input/output digital pin (GPIO)
DSR1 Data Set Ready input for UART1.
MAT1.0 Match output for Timer 1, channel 0.
AD1.3 ADC input 3
P0.13/DTR1/
MAT1.1/AD1.4
39
P0.13 General-purpose input/output digital pin (GPIO)
DTR1 Data Terminal Ready output for UART1
MAT1.1 Match output for Timer 1, channel 1.
AD1.4 ADC input 4
P1.22/
PIPESTAT1
40
P1.22 General-purpose input/output digital pin (GPIO)
PIPESTAT1 Pipeline Status, bit 1. Standard I/O port with
internal pull-up
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 31
P0.14/DCD1/
EINT1/SDA1
41
P0.14 General-purpose input/output digital pin (GPIO)
DCD1 Data Carrier Detect input for UART1
EINT1 External interrupt 1 input.
SDA1 I
2
C1 data input/output. Open-drain output (for
I
2
C-bus compliance) Note: LOW on this pin while RESET
is LOW forces on-chip boot loader to take over control of
the part after reset
VSS
42
Ground: 0 V reference
VDD
43
3.3 V power supply: This is the power supply voltage for
the core and I/O ports
P1.21/
PIPESTAT0
44
P1.21 General-purpose input/output digital pin (GPIO)
PIPESTAT0 Pipeline Status, bit 0. Standard I/O port
with internal pull-up
P0.15/RI1/
EINT2/AD1.5
45
P0.15 General-purpose input/output digital pin (GPIO)
RI1 Ring Indicator input for UART1
EINT2 External interrupt 2 input.
AD1.5 ADC 1, input 5
P0.16/EINT0/
MAT0.2/CAP0.
2
46
P0.16 General-purpose input/output digital pin (GPIO)
EINT0 External interrupt 0 input
MAT0.2 Match output for Timer 0, channel 2
CAP0.2 Capture input for Timer 0, channel 2
P0.17/CAP1.2/
SCK1/MAT1.2
47
P0.17 General-purpose input/output digital pin (GPIO)
CAP1.2 Capture input for Timer 1, channel 2
SCK1 Serial Clock for SSP. Clock output from master
or input to slave
MAT1.2 Match output for Timer 1, channel 2
P1.20/
TRACESYNC
48
P1.20 General-purpose input/output digital pin (GPIO)
TRACESYNC Trace Synchronization. Standard I/O port
with internal pull-up.
Note: LOW on this pin while RESET is LOW enables pins
P1.25:16 to operate as Trace port after reset.
VBAT
49
RTC power supply voltage: 3.3 V on this pin supplies the
power to the RTC
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 32
VSS
50
Ground: 0 V reference
VDD
51
3.3 V power supply: This is the power supply voltage for the core
and I/O ports
P1.30/TMS
52
P1.30 General-purpose input/output digital pin (GPIO)
TMS Test Mode Select for JTAG interface
P0.18/CAP1.3/
MISO1/MAT1.3
53
P0.18 General-purpose input/output digital pin (GPIO)
CAP1.3 Capture input for Timer 1, channel 3.
MISO1 Master In Slave Out for SSP. Data input to SPI
master or data output from SSP slave.
MAT1.3 Match output for Timer 1, channel 3.
P0.19/MAT1.2/
MOSI1/CAP1.2
54
P0.19 General-purpose input/output digital pin (GPIO).
MAT1.2 Match output for Timer 1, channel 2.
MOSI1 Master Out Slave In for SSP. Data output from SSP
master or data input to SSP slave.
CAP1.2 Capture input for Timer 1, channel 2.
P0.20/MAT1.3/
SSEL1/EINT3
55
P0.20 General-purpose input/output digital pin (GPIO)
MAT1.3 Match output for Timer 1, channel 3
SSEL1 Slave Select for SSP. Selects the SSP interface as a
slave
EINT3 External interrupt 3 input
P1.29/TCK
56
P1.29 General-purpose input/output digital pin (GPIO)
TCK Test Clock for JTAG interface
RESET
57
External reset input: A LOW on this pin resets the device,
causing I/O ports and peripherals to take on their default states,
and processor execution to begin at address 0. TTL with
hysteresis, 5 V tolerant.
P0.23/VBUS
58
P0.23 General-purpose input/output digital pin (GPIO)
VBUS Indicates the presence of USB bus power
Note: This signal must be HIGH for USB reset to occur
VSSA
59
Analog ground: 0 V reference. This should nominally be the
same voltage as VSS, but should be isolated to minimize noise
and error
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 33
P1.28/TDI
60
P1.28 General-purpose input/output digital pin (GPIO)
TDI Test Data in for JTAG interface
XTAL2
61
Output from the oscillator amplifier
XTAL1
62
Input to the oscillator circuit and internal clock generator circuits
VREF
63
ADC reference voltage: This should be nominally less than or
equal to the VDD voltage but should be isolated to minimize
noise and error. Level on this pin is used as a reference for
ADC(s) and DAC.
P1.27/TDO
64
P1.27 General-purpose input/output digital pin (GPIO).
TDO Test Data out for JTAG interface.
LPC2148 Architecture
The ARM7TDMI-S is a general-purpose 32-bit microprocessor, which offers high
performance and very low power consumption. The ARM architecture is based on Reduced
Instruction Set Computer (RISC) principles, and the instruction set and related decode
mechanism are much simpler than those of micro programmed Complex Instruction Set
Computers (CISC). This simplicity results in a high instruction throughput and impressive real-
time interrupt response from a small and cost-effective processor core. Pipeline techniques are
employed so that all parts of the processing and memory systems an operate continuously.
Typically, while one instruction is being executed, its successor is being decoded, and a third
instruction is being fetched from memory.
The ARM7TDMI-S processor also employs a unique architectural strategy known as
Thumb, which makes it ideally suited to high-volume applications with memory restrictions, or
applications where code density is an issue. The key idea behind Thumb is that of a super-
reduced instruction set. Essentially, the ARM7TDMI-S processor has two instruction sets:
The standard 32-bit ARM set.
A 16-bit Thumb set.
On-Chip Flash Memory: The LPC2148 incorporate 512 kB flash memory system. This memory
may be used for both code and data storage. Programming of the flash memory may be
accomplished in several ways. It may be programmed In System via the serial port. The
application program may also erase and/or program the flash while the application is running,
allowing a great degree of flexibility for data storage field firmware upgrades, etc. Due to the
architectural solution chosen for an on-chip boot loader, flash memory available for users code
on 500 kB. The LPC2148 flash memory provides a minimum of 100000 erase/write cycles and
20 years of data-retention.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 34
On-chip Static RAM: On-chip static RAM may be used for code and/or data storage. The
SRAM may be accessed as 8-bit, 16-bit, and 32-bit. The LPC2148 provide 32 kB of static RAM.
Also an 8 kB SRAM block intended to be utilized mainly by the USB can also be used as a
general purpose RAM for data storage and code storage and execution.
General purpose parallel I/O (GPIO): Device pins that are not connected to a specific
peripheral function are controlled by the GPIO registers. Pins may be dynamically configured as
inputs or outputs. Separate registers allow setting or clearing any number of outputs
simultaneously. The value of the output register may be read back, as well as the current state
of the port pins.
Fig. 5.4: LPC2148 Block Diagram
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 35
Vectored Interrupt controller: The Vectored Interrupt Controller (VIC) accepts all of the
interrupt request inputs and categorizes them as Fast Interrupt Request (FIQ), vectored
Interrupt Request (IRQ), and non-vectored IRQ as defined by programmable settings. The
programmable assignment scheme means that priorities of interrupts from the various
peripherals can be dynamically assigned and adjusted. Fast interrupt request (FIQ) has the
highest priority. Vectored IRQs have the middle priority. Non-vectored IRQs have the lowest
priority.
External interrupt inputs: The LPC2148 include up to nine edge or level sensitive External
Interrupt Inputs as selectable pin functions. When the pins are combined, external events can
be processed as four independent interrupt signals. The External Interrupt Inputs can optionally
be used to wake-up the processor from Power-down mode. Additionally capture input pins can
also be used as external interrupts without the option to wake the device up from Power-down
mode.
General purpose timers/external event counters: The Timer/Counter is designed to count
cycles of the peripheral clock (PCLK) or an externally supplied clock and optionally generate
interrupts or perform other actions at specified timer values, based on four match registers. It
also includes four capture inputs to trap the timer value when an input signal transitions,
optionally generating an interrupt. Multiple pins can be selected to perform a single capture or
match function, providing an application with or and and, as well as broadcast functions
among them. The LPC2148 can count external events on one of the capture inputs if the
minimum external pulse is equal or longer than a period of the PCLK. In this configuration,
unused capture lines can be selected as regular timer capture inputs, or used as external
interrupts.
+ A 32-bit timer/counter with a programmable 32-bit prescaler
+ External event counter or timer operation
+ Four 32-bit capture channels per timer/counter that can take a snapshot of the timer
value when an input signal transitions. A capture event may also optionally generate an
interrupt.
+ Four 32-bit match registers that allow:
Continuous operation with optional interrupt generation on match.
Stop timer on match with optional interrupt generation.
Reset timer on match with optional interrupt generation.
+ Four external outputs per timer/counter corresponding to match registers, with the
following capabilities:
Set LOW on match.
Set HIGH on match.
Toggle on match.
Do nothing on match.
UARTs: The LPC2148 contains two UARTs. In addition to standard transmit and receive data
lines, the LPC2148 UART1 also provides a full modem control handshake interface. Compared
to previous LPC2000 microcontrollers, UARTs in LPC2148 introduce a fractional baud rate
generator for both UARTs, enabling these microcontrollers to achieve standard baud rates such
as 115200 with any crystal frequency above 2 MHz. In addition, auto-CTS/RTS flow-control
functions are fully implemented in hardware (UART1).
+ 16 B Receive and Transmit FIFOs
+ Register locations conform to 16C550 industry standard
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 36
+ Receiver FIFO trigger points at 1 B, 4 B, 8 B, and 14 B
+ Built-in fractional baud rate generator covering wide range of baud rates without a need
for external crystals of particular values
+ Transmission FIFO control enables implementation of software (XON/XOFF) flow control
on both UARTs
+ LPC2148 UART1 equipped with standard modem interface signals. This module also
provides full support for hardware flow control (auto-CTS/RTS)
I
2
C-bus serial I/O controller: The LPC2148 contains two I
2
C-bus controllers. The I
2
C-bus is bi-
directional, for inter-IC control using only two wires: a serial clock line (SCL), and a serial data
line (SDA). Each device is recognized by a unique address and can operate as either a
receiver-only device. Transmitters and/or receivers can operate in either master or slave mode,
depending on whether the chip has to initiate a data transfer or is only addressed. The I
2
C-bus
is a multi-master bus; it can be controlled by more than one bus master connected to it. The I
2
C-
bus implemented in LPC2148 supports bit rates up to 400 kbit/s (Fast I
2
C-bus).
+ Compliant with standard I
2
C-bus interface
+ Easy to configure as master, slave, or master/slave
+ Programmable clocks allow versatile rate control
+ Bi-directional data transfer between masters and slaves
+ Multi-master bus (no central master)
+ Arbitration between simultaneously transmitting masters without corruption of serial data
on the bus
+ Serial clock synchronization allows devices with different bit rates to communicate via
one serial bus
+ Serial clock synchronization can be used as a handshake mechanism to suspend and
resume serial transfer
+ The I
2
C-bus can be used for test and diagnostic purposes
SPI serial I/O controller: The LPC2148 contains one SPI controller. The SPI is a full duplex
serial interface, designed to handle multiple masters and slaves connected to a given bus. Only
a single master and a single slave can communicate on the interface during a given data
transfer. During a data transfer the master always sends a byte of data to the slave, and the
slave always sends a byte of data to the master.
+ Compliant with SPI specification.
+ Synchronous, Serial, Full Duplex, Communication.
+ Combined SPI master and slave.
+ Maximum data bit rate of one eighth of the input clock rate.
SSP serial I/O controller: The LPC2148 contains one SSP. The SSP controller is capable of
operation on a SPI, 4-wire SSI, or Micro-wire bus. It can interact with multiple masters and
slaves on the bus. However, only a single master and a single slave can communicate on the
bus during a given data transfer. The SSP supports full duplex transfers, with data frames of 4
bits to 16 bits of data flowing from the master to the slave and from the slave to the master.
Often only one of these data flows carries meaningful data.
+ Compatible with Motorolas SPI, TIs 4-wire SSI and National Semiconductors Micro-
wire buses.
+ Synchronous serial communication
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 37
+ Master or slave operation
+ 8-frame FIFOs for both transmit and receive
+ Four bits to 16 bits per frame
10-bit ADC: The LPC2148 contains two analog to digital converters. These converters are
single 10-bit successive approximation analog to digital converters. While ADC0 has six
channels, ADC1 has eight channels. Therefore, total numbers of available ADC inputs are 14.
+ 10-bit successive approximation analog to digital converter
+ Measurement range of 0 V to VREF (2.0 V s VREF s VDDA)
+ Each converter capable of performing more than 400000 10-bit samples per second
+ Every analog input has a dedicated result register to reduce interrupt overhead
+ Burst conversion mode for single or multiple inputs
+ Optional conversion on transition on input pin or timer match signal
+ Global Start command for both converters
10-bit DAC: The DAC enables the LPC2148 to generate a variable analog output. The
maximum DAC output voltage is the VREF voltage.
+ 10-bit DAC
+ Buffered output
+ Power-down mode available
+ Selectable speed versus power
USB 2.0 device controller: The USB is a 4-wire serial bus that supports communication
between a host and a number (127 max) of peripherals. The host controller allocates the USB
bandwidth to attached devices through a token-based protocol. The bus supports hot plugging,
unplugging, and dynamic configuration of the devices. All transactions are initiated by the host
controller. The LPC2148 is equipped with a USB device controller that enables 12 Mbit/s data
exchange with a USB host controller. It consists of a register interface, serial interface engine,
endpoint buffer memory and DMA controller. The serial interface engine decodes the USB data
stream and writes data to the appropriate end point buffer memory. The status of a completed
USB transfer or error condition is indicated via status registers. An interrupt is also generated if
enabled. A DMA controller can transfer data between an endpoint buffer and the USB RAM.
+ Fully compliant with USB 2.0 Full-speed specification
+ Supports 32 physical (16 logical) endpoints
+ Supports control, bulk, interrupt and isochronous endpoints
+ Scalable realization of endpoints at run time
+ Endpoint maximum packet size selection by software at run time
+ RAM message buffer size based on endpoint realization and maximum packet size
+ Supports bus-powered capability with low suspend current
+ Supports DMA transfer on all non-control endpoints
+ One duplex DMA channel serves all endpoints
+ Allows dynamic switching between CPU controlled and DMA modes
Watchdog timer: The purpose of the watchdog is to reset the microcontroller within a
reasonable amount of time if it enters an erroneous state. When enabled, the watchdog will
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 38
generate a system reset if the user program fails to feed (or reload) the watchdog within a
predetermined amount of time.
+ Internally resets chip if not periodically reloaded
+ Debug mode
+ Enabled by software but requires a hardware reset or a watchdog reset/interrupt to be
disabled
+ Incorrect/Incomplete feed sequence causes reset/interrupt if enabled
+ Flag to indicate watchdog reset
+ Programmable 32-bit timer with internal prescaler
+ Selectable time period from (T
cy(PCLK)
256 4) to (T
cy(PCLK)
232 4) in multiples of
T
cy(PCLK)
4.
Real-time clock: The RTC is designed to provide a set of counters to measure time when
normal or idle operating mode is selected. The RTC has been designed to use little power,
making it suitable for battery-powered systems where the CPU is not running continuously (Idle
mode).
+ Measures the passage of time to maintain a calendar and clock.
+ Ultra-low power design to support battery powered systems.
+ Provides Seconds, Minutes, Hours, Day of Month, Month, Year, Day of Week, and Day
of Year.
+ Can use either the RTC dedicated 32 kHz oscillator input or clock derived from the
external crystal/oscillator input at XTAL1. Programmable reference clock divider allows
fine adjustment of the RTC.
+ Dedicated power supply pin can be connected to a battery or the main 3.3 V.
Pulse width modulator: The PWM is based on the standard timer block and inherits all of its
features, although only the PWM function is pinned out on the LPC2148. The timer is designed
to count cycles of the peripheral clock (PCLK) and optionally generate interrupts or perform
other actions when specified timer values occur, based on seven match registers. The PWM
function is also based on match register events.
Crystal oscillator: On-chip integrated oscillator operates with external crystal in range of 1
MHz to 25 MHz. The oscillator output frequency is called f
osc
and the ARM processor clock
frequency is referred to as CCLK for purposes of rate equations, etc. f
osc
and CCLK are the same value unless the PLL is running and connected.
PLL: The PLL accepts an input clock frequency in the range of 10 MHz to 25 MHz. The input
frequency is multiplied up into the range of 10 MHz to 60 MHz with a Current Controlled
Oscillator (CCO). The multiplier can be an integer value from 1 to 32 (in practice, the multiplier
value cannot be higher than 6 on this family of microcontrollers due to the upper frequency limit
of the CPU). The CCO operates in the range of 156 MHz to 320 MHz, so there is an additional
divider in the loop to keep the CCO within its frequency range while the PLL is providing the
desired output frequency. The output divider may be set to divide by 2, 4, 8, or 16 to produce
the output clock. Since the minimum output divider value is 2, it is insured that the PLL output
has a 50 % duty cycle. The PLL is turned off and bypassed following a chip reset and may be
enabled by software. The program must configure and activate the PLL, wait for the PLL to
Lock, then connect to the PLL as a clock source. The PLL settling time is 100 ms.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 39
Reset and wake-up timer: Reset has two sources on the LPC2148: the RESET pin and
watchdog reset. The RESET pin is a Schmitt trigger input pin with an additional glitch filter.
Assertion of chip reset by any source starts the Wake-up Timer, causing the internal chip reset
to remain asserted until the external reset is de-asserted, the oscillator is running, a fixed
number of clocks have passed, and the on-chip flash controller has completed its initialization.
When the internal reset is removed, the processor begins executing at address 0, which is the
reset vector. At that point, all of the processor and peripheral registers have been initialized to
predetermined values. The Wake-up Timer ensures that the oscillator and other analog
functions required for chip operation are fully functional before the processor is allowed to
execute instructions. This is important at power on, all types of reset, and whenever any of the
aforementioned functions are turned off for any reason. Since the oscillator and other functions
are turned off during Power-down mode, any wake-up of the processor from Power-down mode
makes use of the Wake-up Timer.
The Wake-up Timer monitors the crystal oscillator as the means of checking whether it is
safe to begin code execution. When power is applied to the chip, or some event caused the chip
to exit Power-down mode, some time is required for the oscillator to produce a signal of
sufficient amplitude to drive the clock logic.
Brownout detector: The LPC2148 include 2-stage monitoring of the voltage on the VDD pins.
If this voltage falls below 2.9 V, the BOD asserts an interrupt signal to the VIC. This signal can
be enabled for interrupt; if not, software can monitor the signal by reading dedicated register.
The second stage of low voltage detection asserts reset to inactivate the LPC2148 when the
voltage on the VDD pins falls below 2.6 V. This reset prevents alteration of the flash as
operation of the various elements of the chip would otherwise become unreliable due to low
voltage. The BOD circuit maintains this reset down below 1 V, at which point the POR circuitry
maintains the overall reset. Both the 2.9 V and 2.6 V thresholds include some hysteresis. In
normal operation, this hysteresis allows the 2.9V detection to reliably interrupt, or a regularly
executed event loop to sense the condition.
VPB (VLSI Peripheral bus): The VPB divider determines the relationship between the
processor clock (CCLK) and the clock used by peripheral devices (PCLK). The VPB divider
serves two purposes. The first is to provide peripherals with the desired PCLK via VPB bus so
that they can operate at the speed chosen for the ARM processor. In order to achieve this, the
VPB bus may be slowed down to 1/2 to 1/4 of the processor clock rate. The second purpose of
the VPB divider is to allow power savings when an application does not require any peripherals
to run at the full processor rate. Because the VPB divider is connected to the PLL output, the
PLL remains active (if it was running) during Idle mode.
AHB (Advanced High-performance Bus): AHB is a bus protocol published by ARM Ltd.
Company. In addition to previous release, it has the following features:
+ Single edge clock protocol
+ Split transactions
+ Several bus masters & Pipelined operations
+ Single-cycle bus master handover
+ Non-tristate implementation
+ Large bus-widths (64/128 bit)
A simple transaction on the AHB consists of an address phase and a subsequent data
phase (without wait states: only two bus-cycles). Access to the target device is controlled
through a MUX (non-tristate), thereby admitting bus-access to one bus-master at a time.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 40
Memory is the most important unit in the computing system to store, retain and retrieve
the information of the processes. Two basic types of memory are ROM (Read Only Memory)
and RAM (Random Access Memory). Information stored in ROM cannot be modified (at least
not very quickly or easily). The values stored in ROM are always there, whether the power is on
or not. ROM is most commonly used to store system-level programs that we want to have
available at all times. The word RAM is mostly associated with volatile types of memory, where
the information is lost after the power is switched off. Obviously, RAM needs to be writeable in
order for it to do its job of holding programs and data that you are working on. The volatility of
RAM also means that you risk losing what you are working on unless you save it frequently.
RAM is much faster than ROM is, due to the nature of how it stores information. The memories
commonly used are described below.
Memory Types
ROM: ROM is a type of memory that does not lose its contents when the power is turned off.
For this reason, ROM is also called nonvolatile memory. There are different types of ROM, such
as PROM, EPROM, EEPROM, OTP ROM, and FLASH EEPROM.
EPROM: In EPROM, one can program the memory chip and erase it thousands of times. This is
especially necessary during the development of the prototype of an embedded systems based
design. A widely used EPROM is called UV-EPROM where UV stands for ultra-violet. All UV-
EPROM chips have a window that is used to shine UV radiation to erase its contents. The main
problem, and indeed the major disadvantage of UV-EPROM is that it cannot be programmed
while in the system board. To find a solution, EEPROM was invented.
EEPROM: The most important characteristic of this memory is that it does not lose its contents
with the loss of power supply. In this type the data can be erased electrically, using voltage,
which the system operates on. Data can be retained in EEPROM without power supply for up to
many years. In practice, EEPROM memory is used for storing important data or process
parameters.
Flash Memory: Flash EEPROM has become a popular user programmable memory chip since
the early 90s. It is also electrically erasable, but the number of cycles of writing and erasing is
less when compared to EEPROM. In this the process of erasure of the entire contents takes
less than a second, or one might say in a flash, hence its name flash EEPROM. Flash
memories increases the performance of the computer, since flash memory is semiconductor
memory with access time in the range of 100 ns compared with disk access time in the range of
tens of milliseconds.
RAM: RAM memory is called volatile memory since cutting off the power to the IC will result in
the loss of data. The three types of RAM are: SRAM (static RAM), NV-RAM (non-volatile RAM),
and DRAM (dynamic RAM). Storage cells in SRAM are made up of flip-flops and therefore do
not require refreshing in order to keep their data. The problem with the use of flip-flops for
storage cells is that each cell requires at least 6 transistors to build, and the cell holds only 1 bit
of data. NV-RAM combines the best of RAM and ROM: the read and write ability of RAM, plus
the nonvolatile of ROM. DRAM uses capacitors as storage cells. The major advantages of
MEMORY ORGANIZATION
6
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 41
DRAM are high density (capacity), cheaper cost per bit, and lower power consumption per bit.
The disadvantage is that it must be refreshed periodically, due to the fact that capacitor cell
loses its charge.
Memory Architecture
Von-Neumann Architecture: Von Neumann architectures are computer architectures that use
the same storage device for both instructions and data. By treating the instructions in the same
way as the data, the machine could easily change the instructions. In other words the machine
was reprogrammable. Because the machine did not distinguish between instructions and data, it
allowed a program to modify or replicate a program.
Address Bus
Data Bus
Fig. 6.1: Von-Neumann Architecture
Harvard Architecture: The term Harvard architecture originally referred to computer
architectures that uses physically separate storage devices for their instructions and data.
Harvard architecture has separate data and instruction busses, allowing transfers to be
performed simultaneously on both busses.
Fig. 6.2: Harvard Architecture
The Harvard architecture executes instructions in fewer instruction cycles than the Von
Neumann architecture. This is because a much greater amount of instruction parallelism is
possible in the Harvard architecture. Parallelism means that fetches for the next instruction can
take place during the execution of the current instruction, without having to either wait for a
"dead" cycle of the instruction's execution or stop the processor's operation while the next
instruction is being fetched.
The Memory System
ARM memory may be viewed as a linear array of bytes numbered from zero up to 2
32
-1
(byte-addresses memory). Data items may be 8-bit bytes, 16-bit half-words or 32-bit words.
CPU
MEMORY
PROGRAM &
DATA
DATA
MEMORY
PROGRAM
MEMORY
CPU
Data Bus
Address Bus Address Bus
Data Bus
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 42
Words are always aligned on 4-byte boundaries (that is, the two least significant address bits
are zero). Half-words are aligned on even byte boundaries.
LPC2148 Memory Organization
Fig. 6.4: LPC2148 Memory Map
Fig. 6.3: ARM memory organization
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 43
The ARM7TDMI-S has Von Neumann architecture, with a single 32-bit data bus carrying
both instructions and data. Only load, store, and swap instructions can access data from
memory. Data can be 8-bit bytes, 16-bit halfwords, or 32-bit words. Words must be aligned to 4-
byte boundaries. Halfwords must be aligned to 2-byte boundaries. The LPC2148 incorporates
several distinct memory regions, shown above. The basic concept on the LPC2148 is that each
memory area has a "natural" location in the memory map. This is the address range for which
code residing in that area is written. The bulk of each memory space remains permanently fixed
in the same location, eliminating the need to have portions of the code designed to run in
different address ranges. Because of the location of the interrupt vectors on the ARM7
processor (at addresses 0x0000 0000 through 0x0000 001C,, a small portion of the Boot Block
and SRAM spaces need to be re-mapped in order to allow alternative uses of interrupts in the
different operating modes.
Both the AHB and VPB peripheral areas are 2-megabyte spaces, which are divided up
into 128 peripherals. Each peripheral space is 16 kilobytes in size. This allows simplifying the
address decoding for each peripheral. All peripheral register addresses are word aligned (to 32-
bit boundaries) regardless of their size. This eliminates the need for byte lane mapping
hardware that would be required to allow byte (8-bit) or half-word (16-bit) accesses to occur at
smaller boundaries. An implication of this is that word and half-word registers must be accessed
all at once. For example, it is not possible to read or write the upper byte of a word register
separately.
VPB Peripheral Base Address Peripheral Name
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14 22
23
24
25
26
27
28 35
36
37 126
127
0xE000 0000
0xE000 4000
0xE000 8000
0xE000 C000
0xE001 0000
0xE001 4000
0xE001 8000
0xE001 C000
0xE002 0000
0xE002 4000
0xE002 8000
0xE002 C000
0xE003 0000
0xE003 4000
0xE003 8000
0xE005 8000
0xE005 C000
0xE006 0000
0xE006 4000
0xE006 8000
0xE006 C000
0xE007 0000
0xE008 C000
0xE009 0000
0xE009 4000
0xE01F 8000
0xE01F C000
Watchdog timer
Timer 0
Timer 1
UART0
UART1
PWM
Not used
I
2
C0
SPI0
RTC
GPIO
Pin connect block
Not used
ADC0
Not used
I
2
C1
ADC1
Not used
SSP
DAC
Not used
USB
Not used
System Control Block
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 44
On-chip Flash memory Organization
The LPC2148 incorporate a 512 kB Flash memory system. This memory may be used
for both code and data storage. Programming of the Flash memory may be accomplished in
several ways: over the serial built-in JTAG interface, using In System Programming (ISP) and
UART0, or by means of In Application Programming (IAP) capabilities. The application program,
using the IAP functions, may also erase and/or program the Flash while the application is
running, allowing a great degree of flexibility for data storage field firmware upgrades, etc. When
the LPC2148 on-chip boot loader is used, 500 kB of Flash memory is available for user code.
The LPC2148 Flash memory provides minimum of 100,000 erase/write cycles and 20 years of
data-retention.
On-chip Static RAM (SRAM) Organization
On-chip Static RAM (SRAM) may be used for code and/or data storage. The on-chip
SRAM may be accessed as 8-bits, 16-bits, and 32-bits. The LPC2148 provide 32 kB of static
RAM. The LPC2148 SRAM is designed to be accessed as a byte-addressed memory. Word
and halfword accesses to the memory ignore the alignment of the address and access the
naturally aligned value that is addressed (so a memory access ignores address bits 0 and 1 for
word accesses, and ignores bit 0 for halfword accesses). Therefore valid reads and writes
require data accessed as halfwords to originate from addresses with address line 0 being 0
(addresses ending with 0, 2, 4, 6, 8, A, C, and E in hexadecimal notation) and data accessed as
words to originate from addresses with address lines 0 and 1 being 0 (addresses ending with 0,
4, 8, and C in hexadecimal notation). This rule applies to both off and on-chip memory usage.
The SRAM controller incorporates a write-back buffer in order to prevent CPU stalls during
back-to-back writes. The write-back buffer always holds the last data sent by software to the
SRAM. This data is only written to the SRAM when another write is requested by software (the
data is only written to the SRAM when software does another write). If a chip reset occurs,
actual SRAM contents will not reflect the most recent write request (i.e. after a "warm" chip
reset, the SRAM does not reflect the last write operation). Any software that checks SRAM
contents after reset must take this into account. Two identical writes to a location guarantee that
the data will be present after a Reset. Alternatively, a dummy write operation before entering
idle or power-down mode will similarly guarantee that the last data written will be present in
SRAM after a subsequent Reset.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 45
ARM instructions process data held in registers and only access memory with load and
store instructions. ARM instructions commonly take two or three operands.
Example:
ARM processor has 36 instruction formats; the instruction word length is 32-bits.
Instructions are stored word-aligned, so the least significant two bits of instruction addresses are
always zero in ARM state. Some instructions use the least significant bit to determine whether
the code being branched to is Thumb code or ARM code.
Classes of Instructions
The ARM and Thumb instruction sets can be divided into four main classes of instruction:
1. Data processing instructions
2. Load and store instructions
3. Branch instructions
4. Coprocessor instructions
Addressing Modes
The five addressing modes are used by processor are
Mode 1 -Shifter operands for data processing instructions
Mode 2 - Load and store word or unsigned byte
Mode 3 - Load and store half-word or load signed byte
Mode 4 - Load and store multiple
Mode 5 - Load and store coprocessor
In ARM state, all instructions are conditionally executed according to the state of the
CPSR condition codes and the instructions condition field. This field (bits 31:28) determines the
circumstances under which an instruction is to be executed. If the state of the C, N, Z and V
flags fulfill the conditions encoded by the field, the instruction is executed; otherwise it is
ignored. There are 16 possible conditions, each represented by a two-character suffix that can
be appended to the instructions mnemonic. For example, a Branch (B) becomes BEQ for
Branch if Equal, which means the Branch will only be taken if the Z flag is set. The condition
(1111) is reserved, and must not be used. In the absence of a suffix, the condition field of most
instructions is set to Always (AL). This means the instruction will always be executed regardless
of the CPSR condition codes.
Code Suffix Flags Meaning
ADDRESSING MODES AND INSTRUCTION SET
7
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 46
0000
0001
0010
0011
0100
0101
0110
0111
1000
1001
1010
1011
1100
1101
1110
EQ
NE
CS
CC
MI
PL
VS
VC
HI
LS
GE
LT
GT
LE
AL
Z set
Z clear
C set
C clear
N set
N clear
V set
V clear
C set and Z clear
C clear or Z set
N equals V
N not equal to V
Z clear and (N equals V)
Z set or (N not equal to V)
(ignored)
Equal
Not equal
Unsigned higher or same
Unsigned lower
Negative
Positive or Zero
Overflow
No overflow
Unsigned higher
Unsigned lower or same
Greater or equal
Less than
Greater than
Less than or equal
always
Instruction Set Summary
Mnemonic Description
Flags
Affected
ADC {<cond>}{S} <Rd>, <Rn>, <shifter_operand> Add with Carry N, Z, V, C
ADD {<cond>}{S} <Rd>, <Rn>, <shifter_operand> Add N, Z, V, C
AND {<cond>}{S} <Rd>, <Rn>, <shifter_operand> Bit-wise AND N, Z, C
B {<cond>} <target_address>, BL {<cond>}
<target_address>
Branch, Branch and
Link
None
BIC {<cond>}{S} <Rd>, <Rn>, <shifter_operand> Bit Clear N, Z
BX {<cond>} <Rm>
Branch and
Exchange
None
CMN {<cond>} <Rn>, <shifter_operand> Compare Negative N, Z, V, C
CMN {<cond>} <Rn>, <shifter_operand> Compare N, Z, V, C
EOR {<cond>}{S} <Rd>, <Rn>, <shifter_operand> Bit-wise Ex - OR N, Z, C
LDM {<cond>}<addressing_mode>, <Rn>{!},
<registers>
Load Multiple None
LDR {<cond>} <Rd>, <addressing_mode> Load Register None
LDRB {<cond>} <Rd>, <addressing_mode> Load Register Byte None
LDRH {<cond>} <Rd>, <addressing_mode>
Load Register
Halfword
None
LDRSB {<cond>} <Rd>, <addressing_mode> Load Register None
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 47
Signed Byte
LDRSH {<cond>} <Rd>, <addressing_mode>
Load Register
Signed Halfword
None
MLA {<cond>}{S} <Rd >, <Rm>, <Rs>, <Rn> Accumulate
N, Z (C is
unpredictable)
MOV {<cond>}{S} <Rd>, <shifter_operand> Move N, Z, C
MRS {<cond>} <Rd >, CPSR
MRS {<cond>} <Rd >, SPSR
Move PSR into
eneral-Purpose
Register
None
MSR {<cond>} CPSR_<fields>, #<immediate>
MSR {<cond>} CPSR_<fields>, <Rm>
MSR {<cond>} SPSR_<fields>, #<immediate>
MSR {<cond>} SPSR_<fields>, <Rm>
Move to Status
Register from ARM
Register
N/A
MUL {<cond>}{S} <Rd >, <Rm>, <Rs> Multiply
N, Z (C is
unpredictable)
MVN {<cond>}{S} <Rd>, <shifter_operand> Move Negative N, Z, C
ORR {<cond>}{S} <Rd>, <Rn>, <shifter_operand> Bit-wise Inclusive-OR N, Z, C
RSB {<cond>}{S} <Rd>, <Rn>, <shifter_operand> Reverse Subtract N, Z, V, C
RSC {<cond>}{S} <Rd>, <Rn>, <shifter_operand>
Reverse Subtract
with Carry
N, Z, V, C
SBC {<cond>}{S} <Rd>, <Rn>, <shifter_operand> Subtract with Carry N, Z, V, C
SMLAL{<cond>}{S} <Rd_LSW>, <Rd_MSW>, <Rm>,
<Rs>
Signed Multiply-
Accumulate Long
N, Z (V, C are
unpredict)
SMULL{<cond>}{S} <Rd_LSW>, <Rd_MSW>, <Rm>,
<Rs>
Signed Multiply Long
N, Z (V, C are
unpredict)
STM {<cond>}<addressing_mode>, <Rn>{!},
<registers>
Store Multiple None
STR {<cond>} <Rd>, <addressing_mode> Store Register None
STRB {<cond>} <Rd>, <addressing_mode> Store Register Byte None
STRH {<cond>} <Rd>, <addressing_mode> Store Register
Halfword
None
SUB {<cond>}{S} <Rd>, <Rn>, <shifter_operand> Subtract N, Z, V, C
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 48
SWI {<cond>} <immediate_24> Software Interrupt N/A
SWP {<cond>} <Rd>, <Rm>, [<Rn>] Swap None
SWP {<cond>} B <Rd>, <Rm>, [<Rn>] Swap Byte None
TEQ {<cond>} <Rn>, <shifter_operand> Test Equivalence N, Z, C
TST {<cond>} <Rn>, <shifter_operand> Test N, Z, C
UMLAL {<cond>}{S} <Rd_LSW>, <Rd_MSW>,
<Rm>, <Rs>
Unsigned Multiply-
Accumulate Long
N, Z (V, C are
unpredict)
UMULL- {<cond>}{S} <Rd_LSW>, <Rd_MSW>,
<Rm>, <Rs>
Unsigned Multiply
Long
N, Z (V, C are
unpredict)
Assembly Programming Examples
1. Addition Write a program to add two 32-bit numbers
#include <iolpc2148.h>
main
LDR R0,=0x0FF57341
LDR R1,=0xBF230EA1
ADD R3,R0,R1
NOP
END
2. Subtraction Write a program to subtract 4FFFFFEB h from 07A21111h
#include <iolpc2148.h>
main
LDR R0,=0x4FFFFFEB
LDR R1,=0x07A21111
SUB R3,R0,R1
NOP
END
3. Multiplication Write a program to multiply 12345h and 12h
#include <iolpc2148.h>
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 49
main
LDR R0,=0x00012345
LDR R1,=0x00000012
MUL R3,R0,R1
NOP
END
4. Write a program to divide AA19h by 15Eh
#include <iolpc2148.h>
main
LDR R0,=0x0000AA19
LDR R1,=0x0000015E
LOOP1: SUBS R0,R0,R1
BLT LOOP
ADD R2,R2,#0X01
B LOOP1
LOOP: NOP
END
5. Write a program to the compare the contents of the memory locations 00000020h and
00000021h.
#include <iolpc2148.h>
main:
LDR R1,=0X00000020
LDR R0,[R1]
LDR R1,=0X00000021
LDR R3,[R1]
CMP R0,R3
BNE LOOP
MOV R0,#0XFFFFFFFF
B LOOP1
LOOP: MOV R0,#0X00000000
NOP
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 50
LOOP1: END
6. Shift the content of the memory location E0024004h for 5 times and move the result to
the memory location E002008h
#include <iolpc2148.h>
main:
LDR R1,=0XE0024004
LDR R0,[R1]
LSL R0, R0,#0X05
LDR R1,=0XE0028008
STR R0,[R1]
NOP
END
7. Write a program to AND two 32-bit numbers FFFFFFFFh and 0000FFFFh
#include <iolpc2148.h>
main
LDR R0,=0XFFFFFFFF
LDR R1,=0X0000FFFF
AND R0,R0,R1
NOP
END
Exercises:
1. Write a program to add the contents of the memory locations 00000034h and 00000035h.
Store the result to the memory location 00000036h
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 51
2. Write a program to read the data from the location FF204712h and find whether the number
is odd or even
3. Write a program to divide 98ED40h by 9B5h. Move the quotient and remainder to the
memory locations 00000003h and 00000009h
4. Write a program Swap the content of the memory location FFFF0000h
5. Write a program to Move the data 99h to the memory locations from E0000000h to
E000FFFFh
6. Write a program to find the decimal equivalent of the hexadecimal data 45h
7. Write a program to Get n data from the memory locations starting from 00000010h and find
the smallest
8. Write a program to sort an array of elements in the locations starting from E0024000h in
ascending order
9. Write a program to find the complement of the data in the memory location 00000056h
10. Write a program to check whether the ASCII value of the content in the memory location
F1928374h is small letter, capital letter, special character or number.
EMBEDDED C PROGRAMMING
8
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 52
C is a general-purpose language. It is closely associated with the UNIX operating
system for which it was developed. In 1972 Dennis Ritchie at Bell Labs writes C and in 1978 the
publication of the C Programming Language by Kernighan & Ritchie caused a revolution in the
computing world. In 1983, the American National Standards Institute (ANSI) established a
committee to provide a modern, comprehensive definition of C. The resulting definition, the
ANSI standard, or "ANSI C", was completed late 1988. The latest version of Microsoft C is now
considered to be the most powerful and efficient C compiler for personal computers. C stands
for Common. Embedded C is not part of the C language as such. Rather, it is a C language
extension that is the subject of a technical report by the ISO working group named "Extensions
for the Programming Language C to Support Embedded Processors". The hardware I/O
extension is a portability feature of Embedded C. Its goal is to allow easy porting of device-
driver code between systems.
The largest measure of C's success seems to be based on purely practical considerations:
/ The portability of the compiler
/ The standard library concept
/ A powerful and varied repertoire of operators
/ An elegant syntax
Compilers produce hex files that we download into the ROM of the microcontroller. While
Assembly language produces a hex file that is much smaller than C, programming in Assembly
language is tedious and time consuming. C programming, on the other hand, is less time
consuming and much easier to write, but the hex file size produced is much larger than if we
used Assemble language.
The layout of C Programs
pre-processor directives
global declarations
main()
{
local variables to function main ;
statements associated with function main ;
}
function1()
{
local variables to function 1 ;
statements associated with function 1 ;
}
function2()
{
local variables to function 2 ;
statements associated with function 2 ;
}
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 53
Base data types
The compiler uses the following sizes for the various C data types:
char and unsigned char 1 byte
short int and unsigned short int 2 bytes
int and unsigned int 4 bytes
long and unsigned long 4 bytes
long long and unsigned long long 8 bytes
float 4 bytes (32 bits)
double 8 bytes (64 bits)
long double 8 bytes (64 bits)
enum up to 4 bytes
bit fields up to 32 bits
Embedded C Operators
Arithmetic Operators
+ Addition
- Subtraction
* Multiplication
/ Division
% Remainder after integer division (modulus)
Bit-Manipulating Operators
& AND
| OR
~ NOT
^ XOR
<< Shift Left
>> Shift Right
Relational Operators
< Less Than
<= Less Than Or Equal To
> Greater Than
>= Greater Than Or Equal To
Logical Operators
&& AND
|| OR
! NOT
Equality Operators
== Equal To
!= Not Equal To
Unary Operators
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 54
- Minus
++ Increment
-- Decrement
sizeof Size, in bytes
(type) Cast
Libraries
string.h - The standard string.h library is provided using Floating Point options FP(BCD,ALL),
and contains the functions
strrchr, strcat, strncat, strops, strncpy, strcpy, strncmp, strlen, strchr
stdio.h - The standard stdio.h library is provided using Floating Point options FP(BCD,ALL),
and contains the functions
getchar, ungetchar, gets, putchar, puts, printf, sprintf, scanf, sscanf
stdlib.h - The standard stdlib.h library is provided using Floating-Point options FP (BCD, ALL),
and contains the functions
atof, atoi, atol, strtod, strtol, stroul, rand, srand, abs, labs
ctype.h - The standard ctype.h library is provided using Floating-Point options FP (BCD, ALL),
and contains the functions
isalnum, isalpha, isascii, isdigit, isupper, islower, isxdigit, isspace, iscntrl, isprint, ispunct, toascii,
toupper
math.h - The standard math.h library is provided using Floating-Point options FP (BCD, ALL),
and contains the functions
abs, acos, asin, atan, atan2, ceil, fabs, floor, fmod, exp, log, log10, modf, frexp, ldexp, sin, cos,
tan, sinh, cosh, tanh, sqrt, pow, acosf, asinf, atanf, atan2f, ceilf, fabsf, floorf, fmodf, expf, logf,
log10f, modff, frexpf, ldexpf, sinf, cosf, tanf, sinhf, coshf, tanhf, sqrtf, powf, acosl, asinl, atanl,
atan2l, ceill, fabsl, floorl, fmodll, expl, logl, log10l, modfl, frexpl, ldexpl, sinl, cosl, tanl, sinhl,
coshl, tanhl, sqrtl, powl
iolpc2148.h The standard iolpc2148.h library is provided for LPC2148 processor
declarations
Keywords
Reserved keywords specified by the standard C are given in the following table.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 55
There are new reserved keywords for Embedded C. Some of them are pragma,
intrinsic, interrupt, and etc., _int64, _packed are some of the extended keywords used in
ARM compiler. These type qualifiers can be used to instruct the compiler to treat the qualified
type in a special way.
C Programming Examples
1. Write a program to add two 8-bit numbers
#include<iolpc2148.h>
int a,b,c;
void main()
{
a=0x62;
b=0x6C;
c=a+b;
printf("\n\rvalue of c is:%x",c);
}
2. Write a program to find the Factorial of the given number
#include<iolpc2148.h>
#include<stdio.h>
int factorial(long x);
long fact=2;
void main()
{
while(1)
{
printf("\n\rfactorial of given number is:%d",factorial(fact));
fact++;
}
}
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 56
int factorial(long x)
{
long c,f;
f=x;
c=f*(--x);
while(x!=1)
{
c=c*(--x);
}
return(c);
}
3. Write a program to find the largest value in the given array
#include<iolpc2148.h>
#include<stdio.h>
int array[10]={23,12,45,67,89,9,97,107,46,78};
int finding_max(int *p);
void main()
{
printf("\n\r maximum value is:%d",finding_max(array));
}
int finding_max(int *p)
{
int i,max;
max=array[0];
for(i=1;i<10;i++)
{
if(max>p[i])
max=max;
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 57
else
max=p[i];
}
return(max);
}
4. Write a program to find the Prime number
#include<iolpc2148.h>
#include<stdio.h>
int finding_next_prime(int x);
int current_prime=2;
void main()
{
while(1)
{
printf("\n\r Next prime number is :%d",finding_next_prime(current_prime));
current_prime=finding_next_prime(current_prime);
}
}
int finding_next_prime(int x)
{
int a=2,b;
x=x++;
while(a!=x)
{
b=x%a;
if(b==0)
{
x=x++;
a=2;
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 58
}
else
a=a++;
}
return(x);
}
5. Write a program to sorting the array in Ascending Order
#include<iolpc2148.h>
#include<stdio.h>
int array[10]={9,8,7,6,5,4,3,2,1,0};
int sorted[10];
void sorting(int *p);
void display(int *p);
void main()
{
sorting(array);
display(array);
}
void sorting(int *p)
{
int i,j,buffer;
for(i=0;i<10;i++)
for(j=i+1;j<10;j++)
{
if(p[j]<p[i])
{
buffer=p[i];
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 59
p[i]=p[j];
p[j]=buffer;
}
}
}
void display(int *p)
{
int i;
for(i=0;i<10;i++)
printf("\n\rsort is:%d",p[i]);
}
Exercises:
1. Write a program to find the Armstrong number from 0 to 500
(Ex: 153 = (1*1*1)+(5*5*5)+(3*3*3)
2. Convert centigrade into Fahrenheit Scales
3. Write a program to perform logical operations like AND, OR, XOR and NOT
4. Write a program to find whether the entered string is your name or not
5. Write a program to find the number of small letters, capital letters, special characters and
numbers in an array.
6. Write a program to sort the array in descending order
7. Write a program to convert the Hexadecimal value into decimal
8. Write a program to move the data 55h to the memory locations from 00000050h to
00000500h
9. Write a program to generate a divisors of a integer
10. Write a program to check whether a given number is perfect or not (Hint: A positive integer n
is called a perfect number if it is equal to the sum of all of its positive divisors, excluding n
itself. Ex: 1,2,3 are the divisors of 6, the sum of 1,23 is 6. So 6 is the perfect number)
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 60
In computing, an integrated development environment (IDE) is a software application
that provides comprehensive facilities to computer programmers for software development. An
IDE normally consists of a source code editor, a compiler and/or interpreter, build automation
tools, and (usually) a debugger. IAR Systems Embedded Workbench is a fully featured
Integrated Development Environment (IDE) that provides seamless integration and easy access
to all the development tools developed by IAR Systems. IAR Embedded Workbench is a set of
development tools for building and debugging embedded applications using assembler, C and
C++. It provides a completely integrated development environment including a project manager,
editor, build tools and debugger. IAR Embedded Workbench for ARM provides extensive
support for a wide range of ARM devices, hardware debug systems and RTOSs, and generates
very compact and efficient code.
Key features
+ Fully integrated development environment for building and debugging embedded
applications
+ ARM EABI 2.0 (Embedded Application Binary Interface) compatible with other AEABI
compliant tools
+ Advanced optimization technology generating the most compact and efficient code
+ Automatic checking of MISRA C rules for safety-critical systems
+ Support for ARM, Thumb1 and Thumb-2 processor modes and VFP co-processors
+ ETM Trace support via IAR J-Trace
+ Extensive supports for various debug systems, such as simulator, JTAG/SWD, ROM-
monitor and ETM Trace
+ RTOS-aware debugging with built-in or 3rd-party plug-ins
+ Ready-made peripheral register definition files for devices from Analog Devices, Atmel,
Cirrus Logic, Freescale, Handshake Solutions, Intel, Luminary, Marvell, NetSilicon, OKI,
Philips, Samsung, Sharp, STmicroelectronics and Texas Instruments
+ Flash loaders and over 1000 project examples included for most popular devices and
evaluation boards
+ Tight integration with
- IAR PowerPac (RTOS and middleware tools)
- IAR J-Link and IAR J-Trace (hardware debug probes)
- IAR visualSTATE (state machine design and verification tools)
The IAR Embedded Workbench IDE is the framework where all necessary tools are
seamlessly integrated:
The highly optimizing ARM IAR C/C++ Compiler
The ARM IAR Assembler
The versatile IAR XLINK Linker
The IAR XAR Library Builder and the IAR XLIB Librarian
A powerful editor
A project manager
A command line build utility
IAR C-SPY debugger, a state-of-the-art high-level language debugger.
EMBEDDED IDE IAR SYSTEMS EMBEDDED WORKBENCH
9
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 61
The IAR Embedded Workbench IDE is a flexible integrated development environment,
allowing you to develop applications for a variety of different target processors. It provides a
convenient Windows interface for rapid development and debugging.
Steps for creating application code using IAR Systems
Project management
The IAR Embedded Workbench IDE comes with functions that will help you to stay in
control of all project modules, for example, C or C++ source code files, assembler files, include
files, and other related modules. You create workspaces and let them contain one or several
projects. Files can be grouped, and options can be set on all levelsproject, group, or file. This
guide demonstrates a typical development cycle and shows how you use the compiler and the
linker to create a small application for the ARM core. For instance, creating a workspace, setting
up a project with C source files, and compiling and linking your application.
Creating The New Project
1. To create a new project, choose Project>Create New Project. The Create New Project dialog
box appears, which lets you base your new project on a project template.
2. Make sure the Tool chain is set to ARM, and click OK.
3. For this tutorial, select the project template Empty project, which simply creates an empty
project that, uses default project settings.
4. In the standard Save As dialog box that appears, specify where you want to place your
project file, that is, in your newly created projects directory. Type project1 in the File name
box, and click Save to create the new project.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 62
The project will appear in the Workspace window.
A project filewith the filename extension ewpwill be created in the projects directory,
not immediately, but later on when you save the workspace. This file contains information about
your project-specific settings, such as build options. Write the application code in the
corresponding space. The new file can be selected by FileNew File. Write the code and
save the file with the extension of (filename.c or filename.asm or filename.cpp) along with the
file name. If you choose the project template as either ASM, C or C++ while creating a new
project it is not necessary to save the file with the extension.
5. Before you add any files to your project, you should save the workspace. Choose File>Save
Workspace and specify where you want to place your workspace file.
A workspace filewith the filename extension ewwhas now been created in the projects
directory. This file lists all projects that you will add to the workspace.
Adding Files to Project
Creating several groups is a possibility for you to organize your source files logically
according to your project needs. Choose Project>Add Files to open a standard browse dialog
box. Locate the file(s), select them in the file selection list, and click Open to add them to the
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 63
project. Otherwise click the right mouse button on the project in the workspace window and
choose AddAdd filename.c.
Setting Project Options
Now you will set the project options. For application projects, options can be set on all
levels of nodes. First you will set the general options to suit the processor configuration in this
tutorial. Because these options must be the same for the whole build configuration, they must
be set on the project node.
1. Select the project folder icon project1 - Debug in the Workspace window and choose
Project>Options.
The Target options
page in the General Options
category is displayed. In the
general options window the
settings must be
Target Core:
ARM7TDMIS
Output:
Executable
Library Configuration:
Normal
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 64
Click OK to set the options you have specified. The project is now ready to be built.
Linking the Application
Now you should set up the options for the IAR XLINK Linker. Select Project>Options
then select Linker in the Category list to display the XLINK option pages. It is important to
choose the output format that suits your purpose. You might want to load it to a debugger
which means that you need output with debug information.
In the Config window choose the appropriate flash.xcl file. Change the default directory
to the directory path mentioned here for LPC2148.
To compile the file filename.c, select it in the Workspace window. Choose
Project>Compile. Alternatively, click the Compile button in the toolbar or choose the Compile
command from the context menu that appears when you right-click on the selected file in the
Workspace window. The progress will be displayed in the Build messages window. The
executable file in the HEX format will be created in the chosen directory. The HEX file will be
downloaded to the target system by using ISP (In System Programmer).
Now the application code is ready to be run in the IAR C-SPY Debugger where you can
watch variables, set breakpoints, view code in disassembly mode, monitor registers and
memory, and print the program output in the Terminal I/O window. Before starting the IAR C-
SPY Debugger you must set a few C-SPY options.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 65
1. Choose Project>Options and then the Debugger category. On the Setup page, make sure
that you have chosen Simulator from the Driver drop-down list and that Run to main is selected.
Click OK.
2. Choose Project>Debug. Alternatively, click the Debugger button in the toolbar. The IAR C-
SPY Debugger starts with the project1.d79 application loaded. In addition to the windows
already opened in the Embedded Workbench, a set of C-SPY-specific windows are now
available.
At source level, the Step Over and Step Into commands allow you to execute your application a
statement or instruction at a time.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 66
The In-system programming (ISP) is performed without removing the microcontroller
from the system. The in-system programming facility consists of a series of internal hardware
resources coupled with internal firmware to facilitate remote programming of the LPC2148
through the serial port (RS232). This firmware is provided by Philips (NXP). For in-system
programming facility Launch LPC214x_ISP, a software utility is available from Philips.
Steps to download the executable file (HEX file) from PC to Target Board
The flash boot loader code is executed every time the part is powered on or reset. The
loader can execute the ISP command handler or the user application code. A LOW level after
reset at the P0.14 pin is considered as an external hardware request to start the ISP command
handler.
Before downloading do the following
1. Reset the device
2. Keep the pin P0.14 in logical 0 which will forces on-chip boot loader
3. Connect the RS232 cable with the UART 0 lines
4. Connect Power Supply with required rating
If the settings mentioned above are made correct, the message window will show the message
Read Part ID Successfully when you click Read Device ID in the LPC2000 Flash Utility
window.
Then select the file to be loaded in the target device.
IN SYSTEM PROGRAMMING (ISP)
10
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 67
Click Upload to Flash, the previous contents in the memory is erased and the file is
loaded in the Flash memory.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 68
Now the hardware is ready to execute the program. Keep the pin P0.14 in logical 1 state
(connect the pin with 3.3V) opposite to the previous condition and press the RESET switch
once. You can get the result.
There are many benefits to incorporating In-System Programming (ISP) in the
development and production stages of Embedded System Applications In-system programming
is a valuable feature that allows system firmware to be upgraded without disassembling the
embedded system to physically replace memory. Most microcontrollers can be reprogrammed
from a PC or laptop via an inexpensive RS-232 serial interface and a few logic gates. When
launched, the in-system programming feature auto bauds to the detected baud rate and begins
execution of a command-driven, ROM-based bootstrap loader. Embedded designs with in-
system programmability allow generic products to be software-customized right before
shipment. The feature also reduces life cycle cost by permitting existing applications to be
upgraded without disassembling the application. Secure microcontrollers can use this feature to
load the customer's proprietary software into the application where it will be automatically
encrypted and protected against unauthorized access.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 69
Circuits
LPC2148 DESIGN & CIRCUITS
11
LPC2148
Microcontroller
UART 0
UART 1
CAN
Connector
USB
Connector
Power On/Off Switch
Power Supply
Connector
Reset
Switch
Regulator
RS-232
Driver
12 MHz Crystal
Oscillator
LCD
TFT LCD
Connector
Program/
Execution
Mode Switch
Expansion
Header
32.748 kHz
Crystal for
RTC
LEDs
Switch
ADC
Input
P1
CASIO SOCKET
VCC
GND
SW1
POWER ON/OFF SW
1
1
2
2
3
3
VCC
L1
LED
R1
330E
VCC
(POWER ON LED)
L1
LED
R1
330E
VCC
(POWER ON LED)
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 70
C16
22PF
Y1
32.748KHz
3
U5
LPC 2148
P0.21/PWM5/AD1.6/CAP1.3
1
P0.22/AD1.7/CAP0.0/MAT0.0
2
RTXC1
3
P1.19/TRACEPKT3
4
RTXC2
5
VSS
6
VDDA
7
P1.18/TRACEPKT2
8
P0.25/AD0.4/AOUT
9
D+
10
D-
11
P1.17/TRACEPKT1
12
P0.28/AD0.1/CAP0.2/MAT0.2
13
P0.29/AD0.2/CAP0.3/MAT0.3
14
P0.30/AD0.3/EINT3/CAP0.0
15
P1.16/TRACEPKT0
16
P0.31/UP_LED/CONNECT
17
VSS
18
P0.0/TXD0/PWM1
19
P1.31/TRST-
20
P0.1/RXD0/PWM3/EINT0
21
P0.2/SCL0/CAP0.0
22
VDD
23
P1.26/RTCK
24
VSS
25
P0.3/SDA0/MAT0.0/EINT1
26
P0.4/SCK0/CAP0.1/AD0.6
27
P1.25/EXTIN0
28
P0.5/MISO0/MAT0.1/AD0.7
29
P0.6/MOSI0/CAP0.2/AD1.0
30
P0.7/SSEL0/PWM2/EINT2
31
P1.24/TRACECLK
32
P0.8/TXD1/PWM4/AD1.1
33
P0.9/RXD1/PWM6/EINT3
34
P0.10/RTS1/CAP1.0/AD1.2
35
P1.23/PIPESTAT2
36
P0.11/CTS1/CAP1.1/SCL1
37
P0.12/DSR1/MAT1.0/AD1.3
38
P0.13/DTR1/MAT1.1/AD1.4
39
P1.22/PIPESTAT1
40
P0.14/DCD1/EINT1/SDA1
41
VSS
42
VDD
43
P1.21/PIPESTAT0
44
P0.15/RI1/EINT2/AD1.5
45
P0.16/EINT0/MAT0.2/CAP0.2
46
P0.17/CAP1.2/SCK1/MAT1.2
47
P1.20/TRACESYNC
48
VBAT
49
VSS
50
VDD
51
P0.20/MAT1.3/SSEL1/EINT3
55
P1.30/TMS
52
P0.19/MAT1.2/MOSI1/CAP1.2
54
P0.18/CAP1.3/MISO1/MAT1.3
53
P1.29/TCK
56
RESET-
57
P0.23/VBUS
58
VSSA
59
P1.28/TDI
60
XTAL2
61
XTAL1
62
VREF
63
P1.27/TD0
64
C15
22PF
+3.3V
+3.3V
RXD0
TXD0
RESET-
MCLK
XTALIN
P0.2
VBUS
SW0
RXD1
TXD1
SSEL0
MOSI0
MISO0
SCK0
LCD2
LCD1
LCD0
P0.15
P0.14
LED1
LED0
SW1
LCD7
LCD6
LCD5
LCD4
LCD3
P0.25
P0.22
P0.21
P0.20
RX0BF
TX1RTS
TX0RTS
INT
CONNECT
SSEL1
P0.29
ADC
D-
D+
RS
DIOW
P0.3
P1.27
P1.28
P1.29
LCD_EN
P1.30
P1.31
C16
22PF
Y1
32.748KHz
3
U5
LPC 2148
P0.21/PWM5/AD1.6/CAP1.3
1
P0.22/AD1.7/CAP0.0/MAT0.0
2
RTXC1
3
P1.19/TRACEPKT3
4
RTXC2
5
VSS
6
VDDA
7
P1.18/TRACEPKT2
8
P0.25/AD0.4/AOUT
9
D+
10
D-
11
P1.17/TRACEPKT1
12
P0.28/AD0.1/CAP0.2/MAT0.2
13
P0.29/AD0.2/CAP0.3/MAT0.3
14
P0.30/AD0.3/EINT3/CAP0.0
15
P1.16/TRACEPKT0
16
P0.31/UP_LED/CONNECT
17
VSS
18
P0.0/TXD0/PWM1
19
P1.31/TRST-
20
P0.1/RXD0/PWM3/EINT0
21
P0.2/SCL0/CAP0.0
22
VDD
23
P1.26/RTCK
24
VSS
25
P0.3/SDA0/MAT0.0/EINT1
26
P0.4/SCK0/CAP0.1/AD0.6
27
P1.25/EXTIN0
28
P0.5/MISO0/MAT0.1/AD0.7
29
P0.6/MOSI0/CAP0.2/AD1.0
30
P0.7/SSEL0/PWM2/EINT2
31
P1.24/TRACECLK
32
P0.8/TXD1/PWM4/AD1.1
33
P0.9/RXD1/PWM6/EINT3
34
P0.10/RTS1/CAP1.0/AD1.2
C16
22PF
Y1
32.748KHz
3
U5
LPC 2148
P0.21/PWM5/AD1.6/CAP1.3
1
P0.22/AD1.7/CAP0.0/MAT0.0
2
RTXC1
3
P1.19/TRACEPKT3
4
RTXC2
5
VSS
6
VDDA
7
P1.18/TRACEPKT2
8
P0.25/AD0.4/AOUT
9
D+
10
D-
11
P1.17/TRACEPKT1
12
P0.28/AD0.1/CAP0.2/MAT0.2
13
P0.29/AD0.2/CAP0.3/MAT0.3
14
P0.30/AD0.3/EINT3/CAP0.0
15
P1.16/TRACEPKT0
16
P0.31/UP_LED/CONNECT
17
VSS
18
P0.0/TXD0/PWM1
19
P1.31/TRST-
20
P0.1/RXD0/PWM3/EINT0
21
P0.2/SCL0/CAP0.0
22
VDD
23
P1.26/RTCK
24
VSS
25
P0.3/SDA0/MAT0.0/EINT1
26
P0.4/SCK0/CAP0.1/AD0.6
27
P1.25/EXTIN0
28
P0.5/MISO0/MAT0.1/AD0.7
29
P0.6/MOSI0/CAP0.2/AD1.0
30
P0.7/SSEL0/PWM2/EINT2
31
P1.24/TRACECLK
32
P0.8/TXD1/PWM4/AD1.1
33
P0.9/RXD1/PWM6/EINT3
34
P0.10/RTS1/CAP1.0/AD1.2
35
P1.23/PIPESTAT2
36
P0.11/CTS1/CAP1.1/SCL1
37
P0.12/DSR1/MAT1.0/AD1.3
38
P0.13/DTR1/MAT1.1/AD1.4
39
P1.22/PIPESTAT1
40
P0.14/DCD1/EINT1/SDA1
41
VSS
42
VDD
43
P1.21/PIPESTAT0
44
P0.15/RI1/EINT2/AD1.5
45
P0.16/EINT0/MAT0.2/CAP0.2
46
P0.17/CAP1.2/SCK1/MAT1.2
47
P1.20/TRACESYNC
48
VBAT
49
VSS
50
VDD
51
P0.20/MAT1.3/SSEL1/EINT3
55
P1.30/TMS
52
P0.19/MAT1.2/MOSI1/CAP1.2
54
P0.18/CAP1.3/MISO1/MAT1.3
53
P1.29/TCK
56
RESET-
57
P0.23/VBUS
58
VSSA
59
P1.28/TDI
60
XTAL2
61
XTAL1
62
VREF
63
P1.27/TD0
64
C15
22PF
+3.3V
+3.3V
RXD0
TXD0
RESET-
MCLK
XTALIN
P0.2
VBUS
SW0
RXD1
TXD1
SSEL0
MOSI0
MISO0
SCK0
LCD2
LCD1
35
P1.23/PIPESTAT2
36
P0.11/CTS1/CAP1.1/SCL1
37
P0.12/DSR1/MAT1.0/AD1.3
38
P0.13/DTR1/MAT1.1/AD1.4
39
P1.22/PIPESTAT1
40
P0.14/DCD1/EINT1/SDA1
41
VSS
42
VDD
43
P1.21/PIPESTAT0
44
P0.15/RI1/EINT2/AD1.5
45
P0.16/EINT0/MAT0.2/CAP0.2
46
P0.17/CAP1.2/SCK1/MAT1.2
47
P1.20/TRACESYNC
48
VBAT
49
VSS
50
VDD
51
P0.20/MAT1.3/SSEL1/EINT3
55
P1.30/TMS
52
P0.19/MAT1.2/MOSI1/CAP1.2
54
P0.18/CAP1.3/MISO1/MAT1.3
53
P1.29/TCK
56
RESET-
57
P0.23/VBUS
58
VSSA
59
P1.28/TDI
60
XTAL2
61
XTAL1
62
VREF
63
P1.27/TD0
64
C15
22PF
+3.3V
+3.3V
RXD0
TXD0
RESET-
MCLK
XTALIN
P0.2
VBUS
SW0
RXD1
TXD1
SSEL0
MOSI0
MISO0
SCK0
LCD2
LCD1
LCD0
P0.15
P0.14
LED1
LED0
SW1
LCD7
LCD6
LCD5
LCD4
LCD3
P0.25
P0.22
P0.21
P0.20
RX0BF
TX1RTS
TX0RTS
INT
CONNECT
SSEL1
P0.29
ADC
D-
D+
RS
DIOW
P0.3
P1.27
P1.28
P1.29
LCD_EN
P1.30
P1.31
C3
0.1uF
C2
0.1uF
+3.3V
R31
1K
+3.3V
P0.2
R29
1K
P0.3
+3.3V
R26
SW1
+3.3V
R31
1K
+3.3V
P0.2
R29
1K
P0.3
+3.3V
R26
SW1
+3.3V
R17
1K
+3.3V
DIOW
RS
+3.3V
R18
1K
R17
1K
+3.3V
DIOW
RS
+3.3V
R18
1K
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 71
LCD0
LCD4
LCD3
LCD2
LCD1
LCD7
LCD6
LCD5
LCD1
N_LCD DISPLAY
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
R19
1K
TP2
10K
VCC
VCC
VCC
VCC
RS
RESET-
BR
BR
LCD_EN
DIOW
SW5
TINNY SW
1
1
2
2
3
3
SW4
MICRO SW
1 2
U1
MCP1319MT - 45
RST
1
VSS
2
RST
3
MR
4
VDD
5
R38 1K
X1
12Mhz
NC
3
GND
4
OUT
5
VCC
6
R41
100K
+3.3V
+3.3V
VCC
+3.3V
RSTSW-
P0.14
XTALIN
RESET-
RSTSW- RESET
SW0
C17
18pF
SW3
M
I
C
R
O
S
W
R32
1K
+3.3V
R33
100E
SW0
C17
18pF
SW3
M
I
C
R
O
S
W
R32
1K
+3.3V
R33
100E
C17
18pF
SW3
M
I
C
R
O
S
W
R32
1K
+3.3V
R33
100E
SW1
C18
18pF
SW2
M
I
C
R
O
S
W
+3.3V
R35
100E
R34
1K
SW1
C18
18pF
SW2
M
I
C
R
O
S
W
+3.3V
R35
100E
R34
1K
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 72
C9
0.1uF
P2
9 PIN 'D' MALE CON.
5
9
4
8
3
7
2
6
1
C7
0.1uF
C13
0.1uF
L3
LED
U4
ICL232
C1+
1
C1-
3
C2+
4
C2-
5
T1IN
11
R1OUT
12
T2IN
10
R2OUT
9
VCC
16
V+
2
V-
6
GND
15
T1OUT
14
R1IN
13
T2OUT
7
R2IN
8
R8
1.5K
C8
0.1uF
L2
LED
+3.3V
+3.3V
TXD0
RX0_IN
TX0_OUT
RXD0
TX0_OUT
RX0_IN
TX0_OUT
RX0_IN
P4
3 PIN RMC
1
2
3
TX1_OUT
RX1_IN
RXD1
TXD1
RX1_IN
TX1_OUT
C9
0.1uF
P2
9 PIN 'D' MALE CON.
5
9
4
8
3
7
2
6
1
C7
0.1uF
C13
0.1uF
L3
LED
U4
ICL232
C1+
1
C1-
3
C2+
4
C2-
5
T1IN
11
R1OUT
12
T2IN
10
R2OUT
9
VCC
16
V+
2
V-
6
GND
15
T1OUT
14
R1IN
13
T2OUT
7
R2IN
8
R8
1.5K
C8
0.1uF
L2
LED
+3.3V
+3.3V
TXD0
RX0_IN
TX0_OUT
C9
0.1uF
P2
9 PIN 'D' MALE CON.
5
9
4
8
3
7
2
6
1
C7
0.1uF
C13
0.1uF
L3
LED
U4
ICL232
C1+
1
C1-
3
C2+
4
C2-
5
T1IN
11
R1OUT
12
T2IN
10
R2OUT
9
VCC
16
V+
2
V-
6
GND
15
T1OUT
14
R1IN
13
T2OUT
7
R2IN
8
R8
1.5K
C8
0.1uF
L2
LED
+3.3V
+3.3V
TXD0
RX0_IN
TX0_OUT
RXD0
TX0_OUT
RX0_IN
TX0_OUT
RX0_IN
P4
3 PIN RMC
1
2
3
TX1_OUT
RX1_IN
RXD1
TXD1
RX1_IN
TX1_OUT
P0.29
SSEL0
P0.2
P0.25
P1.30
SSEL1
P0.3
P1.29 CONNECT
P5
20 PIN BOX CON.
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
P0.22 P1.27
VBUS P1.28
P1.31
P0.21 P0.15
P0.20
VCC
+3.3V
TXD0
RXD0
SW1
LED0
P7
20 PIN BOX CON.
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
RXD1
SW0
LED1
TXD1
VCC
+3.3V
LCD3
LCD2
LCD1
LCD0
LCD7
LCD6
LCD5
LCD4
RS
P0.29
SSEL0
P0.2
P0.25
P1.30
SSEL1
P0.3
P1.29 CONNECT
P5
20 PIN BOX CON.
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
P0.22 P1.27
VBUS P1.28
P1.31
P0.21 P0.15
P0.20
VCC
+3.3V
TXD0
P0.29
SSEL0
P0.2
P0.25
P1.30
SSEL1
P0.3
P1.29 CONNECT
P5
20 PIN BOX CON.
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
P0.22 P1.27
VBUS P1.28
P1.31
P0.21 P0.15
P0.20
VCC
+3.3V
TXD0
RXD0
SW1
LED0
P7
20 PIN BOX CON.
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
RXD1
SW0
LED1
TXD1
VCC
+3.3V
LCD3
LCD2
LCD1
LCD0
LCD7
LCD6
LCD5
LCD4
RS
C_SSEL0
TX1RTS
TX0RTS
C_SCK0
C_MISO0
INT
C_MOSI0
RX0BF
VCC
SP1
3 PIN SMD JMP 1
3
2
P3
20 PIN BOX CON.
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
+3.3V
C_SSEL0
TX1RTS
TX0RTS
C_SCK0
C_MISO0
INT
C_MOSI0
RX0BF
VCC
SP1
3 PIN SMD JMP 1
3
2
P3
20 PIN BOX CON.
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
19 20
+3.3V
TP1
10K
1
3
2
ADC
+3.3V
R30
100K
TP1
10K
1
3
2
ADC
+3.3V
R30
100K
L5
LED
R21
330E
R20
330E
L6
LED
LED1
LED0
L5
LED
R21
330E
R20
330E
L6
LED
LED1
LED0
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 73
R11 33E
R12
1K
R27
22k
R13
15E
C11
18pF
R14
1.5K
R15 33E
R28 10K
R9
3K
R10
15E
L4
LED
+3.3V
Q1
BC557
2
1
3
D-
+3.3V
C10
18pF
VBUS
D+
CONNECT
P6
USB-B
VCC
1
D-
2
D+
3
GND
5
NC
4
R11 33E
R12
1K
R27
22k
R13
15E
C11
18pF
R14
1.5K
R15 33E
R28 10K
R9
3K
R10
15E
L4
LED
+3.3V
Q1
BC557
2
1
3
D-
+3.3V
C10
18pF
VBUS
D+
CONNECT
P6
USB-B
VCC
1
D-
2
D+
3
GND
5
NC
4
+ C1
10MF/16V
+ C5
10MF/16V
C6
0.1uF
+ C4
10MF/16V R7
100E
R6
10E
U3
LM317
VIN
3
A
D
J
1
VOUT
2
VCC
+3.3V
P8
TFT_DISPLAY
VDIGITAL
1
RESET
2
DIO
3
SCK
4
CS
5
VDISPLAY
6
NC
7
GND
8
LEDGND
9
VLRD
10
R16
33K
+3.3V
+3.3V
T_SCK0
BL_PWR
LCD RST
LCD RST
T_SSEL0
T_MOSI0
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 74
SP5
2
P
I
N
S
M
D
1
2
C_SSEL0
SSEL0
SP4
2
P
I
N
S
M
D
1
2
C_MOSI0
MOSI0
SP2
2
P
I
N
S
M
D
1
2
SCK0
C_SCK0
SP3
2
P
I
N
S
M
D
1
2
C_MISO0
MISO0
+3.3V
+3.3V
C14
0.1uF
R
4
3
.
3
K
SSEL0
R
5
3
.
3
K
MOSI0
U2A
74VHC08
1
2
3
1
4
+3.3V
U2C
74VHC08
9
10
8
U2B
74VHC08
4
5
6
SCK0
R
3
3
.
3
K
R
2
3
.
3
K
U2D
74VHC08
12
13
11
7
MISO0
+3.3V
C_SSEL0
C_MISO0
C_SCK0
C_MOSI0
R36
5.6K
R40 2.2E
+ C19
2
2
0
u
F
/
1
6
V
R39 150E
+ C20
1
0
u
F
/
6
.
3
V
C21
47pF
U7
MC34063A
FB
5
TCAP
3
V
C
C
6
G
N
D
4
D
C
8
P
K
7
SWC
1
SWE
2
D1
IN5819S
R37
1.2K
BD1
220uH
VCC
VCC
BL_PWR
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 75
+3.3V
+3.3V
C12
0.1uF
SSEL1
R
2
4
3
.
3
K
MOSI0
R
2
5
3
.
3
K
+3.3V
U6A
74VHC08
1
2
3
1
4
U6B
74VHC08
4
5
6
U6C
74VHC08
9
10
8
SCK0
R
2
2
3
.
3
K
R
2
3
3
.
3
K
U6D
74VHC08
12
13
11
7
MISO0
+3.3V
T_SSEL0
T_MISO0
T_SCK0
T_MOSI0
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 76
I/O devices are used by a person (or other system) to communicate with a CPU. For
instance, keyboards and mouses are considered input devices of a computer, while monitors
and printers are considered output devices of a computer. The I/O devices are connected
through the ports. One major characteristic of the peripheral interface is whether it is serial or
parallel. In a parallel interface, there are multiple lines connecting the I/O module and the
peripheral, and multiple bits are transferred simultaneously, just as all of the bits of a word are
transferred simultaneously over the data bus. In a serial interface, there is only one line used to
transmit data, and bits must be transmitted one at a time. A parallel interface is commonly used
for higher-speed. The LPC2148 has two 32-bit General Purpose I/O ports. Port 0 is a 32-bit I/O
port with individual direction controls for each bit. Total of 28 pins of the Port 0 can be used as a
general purpose bi-directional digital I/Os while P0.31 provides digital output functions only. The
operation of port 0 pins depends upon the pin function selected via the pin connect block. Pins
P0.24, P0.26 and P0.27 are not available. Port 1 is a 32-bit bi-directional I/O port with individual
direction controls for each bit. The operation of port 1 pins depends upon the pin function
selected via the pin connect block. Pins 0 through 15 of port 1 are not available. PORT0 and
PORT1 are controlled via two groups of 4 registers IO0PIN, IO0SET, IO0DIR, IO0CLR for Port
0 and IO1PIN, IO1SET, IO1DIR, IO1CLR for Port 1.
The LPC2148 never actively outputs more than 3.3V. For logic 0 the voltage on the pin
is 0 volts and for logic 1 the volatage is 3.3V. We can connect digital outputs of a 5V device
directly to the LPC2148. Even if its supply voltage is only 3.3V it tolerates up to 5.5V on its
inputs. Simple output devices include lamps, light emitting diodes and 7-segment LED and LCD
displays, DC motor, Stepper Motor, etc,. The input devices covered are mechanical switches,
multiple position switches and keyboards, Sensors.
Before getting start with interfacing techniques we have to go through the pin connect
block. The pin connect block allows selected pins of the microcontroller to have more than one
function. Configuration registers control the multiplexers to allow connection between the pin
and the on chip peripherals. Peripherals should be connected to the appropriate pins prior to
being activated, and prior to any related interrupt(s) being enabled. Activity of any enabled
peripheral function that is not mapped to a related pin should be considered undefined.
Selection of a single function on a port pin completely excludes all other functions otherwise
available on the same pin. PINSEL0, PINSEL1 and PINSEL2 Registers are used to configure
the pin function. The PINSEL registers control the functions of device pins as shown below.
Pairs of bits in these registers correspond to specific device pins.
00 Primary (default) function, typically GPIO port
01 First alternate function
10 Second alternate function
11 Reserved
The functions of PINSEL0 and PINSEL1 is described below
PERIPHERAL INTERFACING PARALLEL OUTPUT PORT
12
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 77
Pin Function Select Register 0 (PINSEL0 - 0xE002 C000)
Bit Symbol Value Function Reset Value
1:0
3:2
5:4
7:6
9:8
11:10
13:12
15:14
17:16
19:18
21:20
23:22
P0.0
P0.1
P0.2
P0.3
P0.4
P0.5
P0.6
P0.7
P0.8
P0.9
P0.10
P0.11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
GPIO Port 0.0
TXD (UART0)
PWM1
Reserved
GPIO Port 0.1
RxD (UART0)
PWM3
EINT0
GPIO Port 0.2
SCL0 (I2C0)
Capture 0.0 (Timer 0)
Reserved
GPIO Port 0.3
SDA0 (I
2
C0)
Match 0.0 (Timer 0)
EINT1
GPIO Port 0.4
SCK0 (SPI0)
Capture 0.1 (Timer 0)
AD0.6
GPIO Port 0.5
MISO0 (SPI0)
Match 0.1 (Timer 0)
AD0.7
GPIO Port 0.6
MOSI0 (SPI0)
Capture 0.2 (Timer 0)
Reserved or AD1.0
GPIO Port 0.7
SSEL0 (SPI0)
PWM2
EINT2
GPIO Port 0.8
TXD UART1
PWM4
Reserved or AD1.1
GPIO Port 0.9
RxD (UART1)
PWM6
EINT3
GPIO Port 0.10
Reserved or RTS (UART1)
Capture 1.0 (Timer 1)
Reserved or AD1.2
GPIO Port 0.11
0
0
0
0
0
0
0
0
0
0
0
0
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 78
25:24
27:26
29:28
31:30
P0.12
P0.13
P0.14
P0.15
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
Reserved or CTS (UART1)
Capture 1.1 (Timer 1)
SCL1 (I
2
C1)
GPIO Port 0.12
Reserved or DSR (UART1)
Match 1.0 (Timer 1)
Reserved or AD1.3
GPIO Port 0.13
Reserved or DTR (UART1)
Match 1.1 (Timer 1)
Reserved or AD1.4
GPIO Port 0.14
Reserved or DCD (UART1)
EINT1
SDA1 (I
2
C1)
GPIO Port 0.15
Reserved or RI (UART1)
EINT2
Reserved or AD1.5
0
0
0
0
Pin function Select register 1 (PINSEL1 - 0xE002 C004)
Bit Symbol Value Function Reset Value
1:0
3:2
5:4
7:6
9:8
11:10
P0.16
P0.17
P0.18
P0.19
P0.20
P0.21
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
GPIO Port 0.16
EINT0
Match 0.2 (Timer 0)
Capture 0.2 (Timer 0)
GPIO Port 0.17
Capture 1.2 (Timer 1)
SCK1 (SSP)
Match 1.2 (Timer 1)
GPIO Port 0.18
Capture 1.3 (Timer 1)
MISO1 (SSP)
Match 1.3 (Timer 1)
GPIO Port 0.19
Match 1.2 (Timer 1)
MOSI1 (SSP)
Capture 1.2 (Timer 1)
GPIO Port 0.20
Match 1.3 (Timer 1)
SSEL1 (SSP)
EINT3
GPIO Port 0.21
PWM5
Reserved or AD1.6
Capture 1.3 (Timer 1)
0
0
0
0
0
0
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 79
13:12
15:14
17:16
19:18
21:20
23:22
25:24
27:26
29:28
31:30
P0.22
P0.23
P0.24
P0.25
P0.26
P0.27
P0.28
P0.29
P0.30
P0.31
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
00
01
10
11
GPIO Port 0.22
Reserved or AD1.7
Capture 0.0 (Timer 0)
Match 0.0 (Timer 0)
GPIO Port 0.23
VBUS
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
GPIO Port 0.25
AD0.4
Reserved or Aout(DAC)
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
Reserved
GPIO Port 0.28
AD0.1
Capture 0.2 (Timer 0)
Match 0.2 (Timer 0)
GPIO Port 0.29
AD0.2
Capture 0.3 (Timer 0)
Match 0.3 (Timer 0)
GPIO Port 0.30
AD0.3
EINT3
Capture 0.0 (Timer 0)
GPO Port only
UP_LED
CONNECT
Reserved
0
0
0
0
0
0
0
0
0
0
Pin function Select register 2 (PINSEL2 - 0xE002 C014)
Bit Symbol Value Function Reset Value
1:0
-
-
Reserved, user software should not
write ones to reserved bits. The value
NA
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 80
2
3
31:4
GPIO/DEBUG
GPIO/TRACE
-
0
1
0
1
-
read from a reserved bit is not defined.
Pins P1.36-26 are used as GPIO pins.
Pins P1.36-26 are used as a Debug
port.
Pins P1.25-16 are used as GPIO pins.
Pins P1.25-16 are used as a Trace
port.
Reserved, user software should not
write ones to reserved bits. The value
read from a reserved bit is not defined.
P1.26/RTCK
P1.20/TRACESYNC
NA
General-purpose Register Map
Register
Name
Description
Acc
ess
Reset Value Address
IO0PIN
IO1PIN
IO0SET
IO1SET
IO0CLR
IO1CLR
IO0DIR
IO1DIR
FIO0DIR
FIO1DIR
FIO0MASK
FIO1MASK
FIO0PIN
FIO1PIN
FIO0SET
FIO1SET
FIO0CLR
FIO1CLR
GPIO Port 0 Pin Value Register
GPIO Port 1 Pin Value Register
GPIO Port 0 Ouptut Set Register
GPIO Port 1 Ouptut Set Register
GPIO Port 0 Output Clear Register
GPIO Port 1 Output Clear Register
GPIO Port 0 Direction Control Register
GPIO Port 1 Direction Control Register
Fast GPIO Port 0 Direction control
register
Fast GPIO Port 0 Direction control
register
Fast Mask Register for Port 0
Fast Mask Register for Port 1
Fast Port 0 Pin value register
Fast Port 1 Pin value register
Fast Port 0 Output Set register
Fast Port 1 Output Set register
Fast Port 0 Output Clear register
Fast Port 1 Output Clear register
R/W
R/W
R/W
R/W
WO
WO
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
WO
WO
NA
NA
0x00000000
0x00000000
0x00000000
0x00000000
0x00000000
0x00000000
0x00000000
0x00000000
0x00000000
0x00000000
0x00000000
0x00000000
0x00000000
0x00000000
0x00000000
0x00000000
0xE0028000
0xE0028010
0xE0028004
0xE0028014
0xE002800C
0xE002801C
0xE0028008
0xE0028018
0X3FFFC000
0X3FFFC020
0X3FFFC010
0X3FFFC030
0x3FFFC014
0x3FFFC034
0x3FFFC018
0x3FFFC038
0x3FFFC01C
0x3FFFC03C
Note:
1. For Direction Control Register
0 Controlled pin is input
1 Controlled pin is output
2. FIO0DIR, FIO1DIR, FIO0MASK, FIO1MASK, and etc., are some of the byte-accessible and
half-word accessible Registers.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 81
3. Byte Accessible registers (8-bit), FIO0DIR0, FIO0DIR1, FIO0DIR2, FIO0DIR3
4. Half-word Accessible Register (16-bit)
FIO0DIRL (0x3FFF C000), FIO0DIRU (0x3FFF C002)
Example
State of the output configured GPIO pin is determined by writes into the pins port
IOSET and IOCLR registers. Last of these accesses to the IOSET/IOCLR register will
determine the final output of a pin. In case of a code:
1. IO0DIR = 0x0000 0080 ;pin P0.7 configured as output
IO0CLR = 0x0000 0080 ;P0.7 goes LOW
IO0SET = 0x0000 0080 ;P0.7 goes HIGH
IO0CLR = 0x0000 0080 ;P0.7 goes LOW
6. IO0PIN = (IO0PIN && 0xFFFF00FF) || 0x0000A500
3. FIO0MASK = 0xFFFF00FF; //using 32-bit Fast GPIO
FIO0PIN = 0x0000A500;
4. FIO0MASKL = 0x00FF; //using 16-bit Fast GPIO
FIO0PINL = 0xA500;
5. FIO0PIN1 = 0xA5; //using 8-bit Fast GPIO
Interfacing with LED (Light Emitting Diode)
Therefore, when interfacing an LED to a TTL output, the maximum current through the
LED is 16 mA. The features of LEDs are listed below
_ Lower power consumption
_ Require series resistors to limit the current
_ Displaying decimal digits
Fig. 12.1: LED, LED Symbol, Interfacing Circuit
LED
330O
P1.24
LED
330O
P1.24
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 82
LED lighting is an emerging technology with many home applications such as LED
Christmas lights, LED rope lights, LED spotlights, etc. LED bulbs last over 50,000 hours.
Program - Switch on and switch off the LEDs with the regular interval
Interfacing with Seven-segment LED
_ It is an image sequence of a "LED" display
_ Composed of seven elements, Individually on or off
_ Optional DP decimal point is used for the display of non-integer numbers
_ Displaying ten decimal numerals and the six hexadecimal "letter digits" (AF)
#include <iolpc2148.h>
main: NOP
LDR R0,=IO1DIR
MOV R1,#0X00FF0000
STR R1,[R0]
LDR R0,=IO1PIN
MOV R1,#0X00550000
STR R1,[R0]
LDR R1,=0X000FFFFF
BL DELAY
LDR R0,=IO1PIN
MOV R1,#0X00AA0000
STR R1,[R0]
BL DELAY
B main
DELAY:
LDR R1,=0X000FFFFF
LOOP: SUBS R1,R1,#0X01
BGT LOOP
MOV PC,LR
END main
#include "iolpc2148.h"
void delay();
void main()
{
IO1DIR=0xFF000000;
loop:
IO1SET=0xFF000000;
delay();
IO1CLR=0xFF000000;
delay();
goto loop;
}
void delay()
{
long int j;
for(j=0;j<100000;j++);
}
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 83
Fig.12.2: 7-Segment LED, construction and Interfacing Circuit
Seven-segment displays are found in Pocket calculators, Sign boards, Counting circuits
and etc..
Program Display 0 to 9 in 7-segment display
#include "iolpc2148.h"
unsigned char disp[10]={ 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
void delay();
unsigned int i;
void main()
{
IO1DIR=0xFF000000;
while(1)
{
for(i=0;i<10;i++)
{
IO1PIN=disp[i]<<24;
delay();
}
}
a
dp
b
c d e
f g
vcc
330 ohm
P1.24/TRACECLK
P1.27/AD0
P1.28/AD1
P1.29/TCK
P1.25/EXTIN0
P1.26/RTCK
P1.31/TRST
P1.30/TMS
20
56
52
24
64
60
32
28 b
a
dp
g
f
e
d
c
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 84
}
void delay()
{
long int i;
for(i=0;i<1000000;i++);
}
Interfacing with LCD (Liquid Crystal Display)
Liquid crystals are a phase of matter whose order is intermediate between that of a liquid
and that of a crystal. The molecules are typically rod-shaped organic matters about 25
Angstroms in length and their ordering is a function of temperature. The molecular orientation
can be controlled with applied electric fields. LCD is made up of two sheets of polarizing
material with the liquid crystal solution between them. An electric current passed through the
liquid causes the crystals to align so that light cannot pass through them, which results in
display of character as per the applied voltage in its data lines. The driver is provided to drive
the LCD. It stores the display data transferred from the microcontroller in the internal display
RAM and generates dot matrix liquid crystal driving signals. Each bit data of display RAM
corresponds to on/off state of a dot of a liquid crystal display.
LCDs available in two models: character LCD and Graphics LCD. The character LCD
displays ASCII values and graphics LCD displays graphics. Character LCDs are available in
various kinds of models.
1. No. Of characters Lines: 81, 161, 162, 164, 204, 404,
2. Dots Dots: 12232, 12864, 240128, 320240,.
3. Color: Yellow, Green, Gray, Blue.
Graphics LCDs are also available with different sizes and colors.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 85
Fig. 12.3: LCD Types, Character LCD, LCD pin diagram, Interfacing Circuit
The pin description for character LCD is given below.
V
CC
, GND AND V
0
- While V
CC
and V
SS
provide +5V and ground, respectively; V
0
is used for
controlling LCD contrast.
RS (Register Select) - If RS = 0, the instruction command code register is selected, allowing
the user to send a command such as clear display, cursor at home, etc. If RS = 1, the data
register is selected, allowing the user to send data to be displayed on the LCD.
RW (Read/Write) - RW allows the user to write information to the LCD or read information from
it. RW=1 when reading; RW=0 when writing.
EN (Enable) - The LCD to latch information presented to its data pins uses the enable pin.
When data is supplied to data pins, a high to low pulse must be applied to this pin in order for
the LCD to latch in the data present at the data pins.
D0 D7 - The 8-bit data pins, are used to send information to the LCD or read the contents of
the LCDs internal registers. To display letters and numbers, we send ASCII codes for the letters
A-Z, a-z, and numbers 0-9 to these pins while making RS = 1.
L
C
D
VCC
1
2
10
9
8
7
6
5
4
3
16
15
14
13
12
11
RS
D5
D4
D3
D2
D1
D0
EN
RW
D7
D6
BR1
VCC 10K
VCC
BR1
P1.24/TRACECLK
P1.25/EXTINO
P1.26/AD0
P1.22/PIPESTAT1
P1.23/PIPESTST2
P1.19/TRACEPKT3
P1.20/TRACESYNC
P1.21/PIPESTST0
P1.17/TRACEPKT1
P1.18/TRACEPKT2
40
P1.16/TRACEPKT0
28
32
24
8
12
16
44
4
48
36
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 86
Program - Display Vi Microsystems in the first line and Chennai-96 in the second line
#include<IOLPC2148.h>
void delay();
#define RS IO1PIN_bit.P1_24
#define RW IO1PIN_bit.P1_25
#define EN IO1PIN_bit.P1_26
#define Busyflag IO1PIN_bit.P1_23
unsigned char command[5]={0x38,0x01,0x06,0x0C,0x80};
unsigned char dat[16]="Vi Microsystems";
unsigned char dat1[16]= Chennai 96 ;
int i;
void main()
{
IO1DIR = 0x07FF0000;
RS=0;
RW=0;
EN=0;
delay();
for(i=0;i<5;i++)
{
delay();
IO1DIR=0x07FF0000;
IO1PIN=(command[i]<<16);
RS=0;
RW=0;
EN=1;
EN=0;
}
for(i=0;i<16;i++)
{
delay();
IO1DIR=0x07FF0000;
IO1PIN=(dat[i]<<16);
RS=1;
RW=0;
EN=1;
EN=0;
}
delay();
IO1DIR=0x07FF0000;
IO1PIN=(0xC0<<16);
RS=0;
RW=0;
EN=1;
EN=0;
for(i=0;i<16;i++)
{
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 87
delay();
IO1DIR=0x07FF0000;
IO1PIN=(dat1[i]<<16);
RS=1;
RW=0;
EN=1;
EN=0;
}
while(1);
}
void delay()
{
RW=1;
RS=0;
EN=0;
IO1DIR=0x07000000;
busy:
EN=0;
EN=1;
if(Busyflag==1)
goto busy;
EN=0;
}
LCD is used in widespread applications due to the following reasons:
1. The declining prices of LCDs.
2. The ability to display numbers, characters, and graphics.
3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of the task of
refreshing the LCD.
4. Ease of programming for characters and graphics.
Stepper Motor Interfacing
Stepper motors or Stepping motors are electromagnetic, rotary, incremental devices,
which convert digital pulses into mechanical rotation. The amount of rotation is directly
proportional to the number of pulses and the speed of rotation is relative to the frequency of
those pulses. Stepping motors are simple to drive in an open loop configuration and for their
size provide excellent torque at low speed. Although various types of stepping motor have been
developed, they all fall into three basic categories; variable reluctance (V.R), permanent magnet
and hybrid stepper motors.
The stepper motor can be operated in three different stepping modes, namely, full-step,
half-step, and micro-step. The main feature of this switching sequence is that you can double
the resolution of the stepper motor by causing the rotor to move half the distance it does when
the full-step switching sequence is used. This means that a 200-step motor, which has a
resolution of 1.8, will have a resolution of 400 steps and 0.9. The stepper motor uses a four-
step switching sequence, which is called a full-step switching sequence. The stepper motor
uses a eight-step switching sequence, which is called a half-step switching sequence. The full-
step and half-step motors tend to be slightly jerky in their operation as the motor moves from
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 88
step to step. The amount of resolution is also limited by the number of physical poles that the
rotor can have. The amount of resolution (number of steps) can be in-creased by manipulating
the current that the controller sends to the motor during each step. In fact it is possible for the
controller to reach as many as 500 micro steps for a full-step sequence, which will provide
100,000 steps for each revolution.
In order to keep the motors power loss within a reasonable limit, the current in the windings
must be controlled. The stepper motor driver circuit has two major tasks:
To change the current and flux direction in the phase windings
To drive a controllable amount of current through the windings, and enabling as
short current rise and fall times as possible for good high speed performance.
Darlington transistors are normally used for driving circuit. Each winding need a
darlington transistor, which is a transistor pair. L298 is the single IC that performs the same
function of darlington transistors. The interfacing circuit is shown below.
Fig. 12.4: Stepper Motor and Connection Diagram
Stepper
Motor
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 89
Program Rotate the stepper motor for 360 degrees in forward diretion and 360 degrees
in reverse direction
#include<IOLPC2148.h>
void stepperfwd(unsigned long int rot);
void stepperrev(unsigned long int rot);
void stepperdelay();
void main()
{
stepperfwd(50);
stepperdelay();
stepperrev(50);
while(1);
}
void stepperfwd(unsigned long int rot)
{
int s;
IO0DIR = 0x000000F0;
for(s=0;s<rot;s++)
{
IO0PIN=0x00000090;
stepperdelay();
IO0PIN=0x00000050;
stepperdelay();
IO0PIN=0x00060060;
stepperdelay();
IO0PIN=0x000000A0;
stepperdelay();
}
}
void stepperrev(unsigned long int rot)
{
int s;
IO0DIR = 0x000000F0;
for(s=0;s<rot;s++)
{
IO0PIN=0x000000A0;
stepperdelay();
IO0PIN=0x00000060;
stepperdelay();
IO0PIN=0x00060050;
stepperdelay();
IO0PIN=0x00000090;
stepperdelay();
}
}
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 90
void stepperdelay()
{
unsigned long k;
for(k=0;k<5000;k++);
}
The benefits offered by stepping motors include:
- a simple and cost effective design
- high reliability
- maintenance free (no brushes)
- open loop (no feed back device required)
- known limit to the 'dynamic position error'
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 91
Input port is essential to interface with the external world. The input devices are
switches, keys, ADC, and sensors. IO0DIR and IO1DIR have default value of 0x00000000 so
by default port pins are configured as input. Also, a pin once configured as output can not be
used as input unless the value of corresponding IODIR register is changed.
Let us see the working of the input port. When a HIGH is applied to a TTL input it draws
very little current. When a LOW is applied to a TTL input it sources approximately 4 mA. When
the digital input is HIGH the transistor will be turned on. This results in a direct path from the
port pin to ground, therefore the pin is logic 0. When the digital input is LOW the transistor is off
which means there is no path for current from the collector to the emitter, therefore the port pin
will read 5V. This circuit results in logic inversion, but this should not be a problem as inverting
the port pin through software is very easy.
Interfacing with Switch
An electrical switch is any device used to interrupt the flow of electrons in a circuit.
Switches are essentially binary devices: they are either completely on ("closed") or completely
off ("open").. In the simplest case, a switch has two pieces of metal called contacts that touch to
make a circuit, and separate to break the circuit. Push button switch is one of the mostly used
type.
Fig.13.1: Switch, Symbol and interfacing circuit
PERIPHERAL INTERFACING INPUT PORT
13
P1.16/TRACEPKT0
1 2
1 2
1 2
1 2
1 2
1 2
1 2
1 2
40
8
12
16
48
44
4
36 P1.23/PIPESTST2
P1.21/PIPESTST0
P1.22/PIPESTAT1
P1.19/TRACEPKT3
P1.20/TRACESYNC
P1.17/TRACEPKT1
P1.18/TRACEPKT2
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 92
When the switch is open, no current flows through the resistor and therefore the voltage
on the microcontroller pin is 3.3 V. When the switch is closed the pin is connected directly to
ground. As before, when the TTL input is HIGH practically no current flows in the circuit and
when the input is LOW there is a direct current for the 3 A that may flow from the pin.
A push button switch is used to either close or open an electrical circuit depending on
the application. Push button switches are used in various applications such as industrial
equipment control handles, outdoor controls, mobile communication terminals, and medical
equipment, and etc.
Program Read the keys and indicate using LEDs
#include "iolpc2148.h"
void delay();
#define SW1 IO0PIN_bit.P0_10
#define SW2 IO0PIN_bit.P0_11
void main()
{
loop:
IO0DIR=0x00000000;
if(SW1==0)
{
IO0DIR=0x00003000;
IO0PIN=0x00001000;
delay();
}
else if(SW2==0)
{
IO0DIR=0x00003000;
IO0PIN=0x00002000;
delay();
}
else
{
IO0DIR=0x00003000;
IO0PIN=0x00000000;
}
goto loop;
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 93
}
void delay()
{
long int i;
for(i=0;i<10000;i++);
}
Interfacing with Sensor
A sensor is a device, which measures a physical quantity and converts it into a signal,
which can be read by an observer or by an instrument. Sensors are classified according to the
physical properties. Temperature sensor, pressure sensor, humidity sensor, wind velocity
sensor, acceleration sensor, flow sensor, level sensor, strain gauge, touching sensor, proximity
sensors are the most common types of sensors. Touching sensor and proximity sensors are
interfaced with microcontroller through the digital input lines. The remaining sensors are
connected through Analog to Digital Converter. Here the IR (Infra Red) sensor is explained in
detail. An Infra Red sensor is an electronic device, which measures infrared light radiating from
objects in its field of view.
Fig.13.2: IR sensor, Symbol and interfacing circuit
A
LED
2N2222A
2N2222A
1K
10K
68K 470 ohm
K
0
0
0
HI
VCC 5V
o/p
To
Microcontroller
Pin
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 94
IR sensors are used in edge detection in robotics, Digital cameras and for object
counting circuits.
Program in C Display the number of objects passed through using 7-segment LED
#include<IOLPC2148.h>
void delay();
#define sensor IO0PIN_bit.P0_20
unsigned char disp[10]={ 0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90};
unsigned int count;
void main()
{
while(1)
{
IO0DIR=0X00000000;
if(sensor==1)
{
count=count+1;
if(count>9)
count=0;
IO0DIR=0xFF000000;
IO0PIN=disp[count]<<24;
while(sensor==1);
delay();
}
}
}
void delay()
{
int m;
for(m=0;m<200;m++);
}
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 95
Serial port is a serial communication physical interface through which information
transfers in or out one bit at a time (contrast parallel port). The name "serial" comes from the
fact that a serial port "serializes" data. That is, it takes a byte of data and transmits the 8 bits in
the byte one at a time. The advantage is that a serial port needs only one wire to transmit the 8
bits (while a parallel port needs 8). The disadvantage is that it takes 8 times longer to transmit
the data than it would if there were 8 wires. Serial ports lower cable costs and make cables
smaller.
There are two basic types of serial communications, synchronous and asynchronous.
With synchronous communications, the two devices initially synchronize themselves to each
other, and then continually send characters to stay in sync. Even when data is not really being
sent, a constant flow of bits allows each device to know where the other is at any given time.
That is, each character that is sent is either actual data or an idle character. Synchronous
communications allows faster data transfer rates than asynchronous methods, because
additional bits to mark the beginning and end of each data byte are not required.
Fig.14.1: Synchronous Data Transfer
Asynchronous means "no synchronization", and thus does not require sending and
receiving idle characters. However, the beginning and end of each byte of data must be
identified by start and stop bits. The start bit indicates when the data byte is about to begin and
the stop bit signals when it ends. The requirement to send these additional two bits causes
asynchronous communication to be slightly slower than synchronous however it has the
advantage that the processor does not have to deal with the additional idle characters. An
asynchronous line that is idle is identified with a value of 1 (also called a mark state). By using
this value to indicate that no data is currently being sent, the devices are able to distinguish
between an idle state and a disconnected line. When a character is about to be transmitted, a
start bit is sent. A start bit has a value of 0 (also called a space state). Thus, when the line
switches from a value of 1 to a value of 0, the receiver is alerted that a data character is about
to be sent.
Fig.14.2: Asynchronous Data Transfer
SERIAL PORT (UART)
14
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 96
SPI (Serial Peripheral Interface) and I
2
C (Inter-Integrated Circuit) are the examples for
synchronous mode of data transfer. UART (Universal Asynchronous Receiver Transmitter),
USB (Universal Serial Bus), Ethernet, CAN (Controller Area Network) are the examples for
asynchronous type of communication.
One of the LPC2148s many powerful features is its integrated UART, otherwise known
as a serial port. The fact that the LPC2148 has an integrated serial port means that you may
very easily read and write values to the serial port. If it were not for the integrated serial port,
writing a byte to a serial line would be a rather tedious process requiring turning on and off one
of the I/O lines in rapid succession to properly "clock out" each individual bit, including start bits,
stop bits, and parity bits. However, we do not have to do this. Instead, we simply need to
configure the serial ports operation mode and baud rate. Once configured, all we have to do is
write to an SFR to write a value to the serial port or read the same SFR to read a value from the
serial port. The LPC2148 will automatically let us know when it has finished sending the
character we wrote and will also let us know whenever it has received a byte so that we can
process it. We do not have to worry about transmission at the bit level--which saves us quite a
bit of coding and processing time. UART or Serial ports, also called communication (COM)
ports, RS-232 ports are bi-directional. The LPC2148 contain two UARTs. In addition to standard
transmit and receive data lines, the UART1 also provides a full modem control handshake
interface.
SFRs Associated with Serial UART 0
SFR Description Access Reset Value Address
U0RBR
U0THR
U0DLL
U0DLM
U0IER
U0IIR
U0FCR
U0LCR
U0LSR
U0SCR
U0ACR
U0FDR
U0TER
Receiver Buffer Register
Transmit Holding Register
Divisor Latch LSB
Divisor Latch MSB
Interrupt Enable Register
Interrupt ID Register
FIFO Control Register
Line Control Register
Line Status Register
Scratch Pad Reg.
Auto-baud Control Register
Fractional Divider Register
TX. Enable Reg.
RO
WO
R/W
R/W
R/W
RO
WO
R/W
RO
R/W
R/W
R/W
NA
NA
0x01
0x00
0x00
0x01
0x00
0x00
0x60
0x00
0x00
0x10
0x80
0xE000 C000 (DLAB=0)
0xE000 C000 (DLAB=0)
0xE000 C000 (DLAB=1)
0xE000 C004 (DLAB=1)
0xE000 C004 (DLAB=0)
0xE000 C008
0xE000 C008
0xE000 C00C
0xE000 C014
0xE000 C01C
0xE000 C020
0xE000 C028
0xE000 C030
All of the SFRs associated with UART0 most important SFRs are explained in detail.
Baud Rate Calculation
The UART0 Divisor Latch is part of the UART0 Fractional Baud Rate Generator and
holds the value used to divide the clock supplied by the fractional prescaler in order to produce
the baud rate clock, which must be 16x the desired baud rate. The U0DLL and U0DLM registers
together form a 16 bit divisor where U0DLL contains the lower 8 bits of the divisor and U0DLM
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 97
contains the higher 8 bits of the divisor. The Divisor Latch Access Bit (DLAB) in U0LCR must be
one in order to access the UART0 Divisor Latches. The UART0 Fractional Divider Register
(U0FDR) controls the clock prescaler for the baud rate generation and can be read and written
at users discretion. This prescaler takes the VPB clock and generates an output clock per
specified fractional requirements.
UART0 Fractional Divider Register
UART0 baudrate can be calculated as:
Where PCLK is the peripheral clock, U0DLM and U0DLL are the standard UART0 baud
rate divider registers, and DIVADDVAL and MULVAL are UART0 fractional baudrate generator
specific parameters.
The value of MULVAL and DIVADDVAL should comply to the following conditions:
1. 0 < MULVAL 15
2. 0 DIVADDVAL 15
UART0 Interrupt Enable Register
The U0IER is used to enable UART0 interrupt sources.
RBR Interrupt Enable - Enables the Receive Data Available interrupt for UART0. It also
controls the Character Receive Time-out interrupt.
0 Disable the RDA interrupts.
1 Enable the RDA interrupts.
THRE Interrupt Enable - Enables the THRE interrupt for UART0. The status of this can be read
from U0LSR.
0 Disable the THRE interrupts.
1 Enable the THRE interrupts.
RX Line Status Interrupt Enable - Enables the UART0 RX line status interrupts. The status of
this interrupt can be read from U0LSR.
0 Disable the RX line status interrupts.
1 Enable the RX line status interrupts.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 98
ABTOIntEn - Enables the auto-baud time-out interrupt.
0 Disable Auto-baud Time-out Interrupt.
1 Enable Auto-baud Time-out Interrupt.
ABEOIntEn - Enables the end of auto-baud interrupt.
0 Disable End of Auto-baud Interrupt.
1 Enable End of Auto-baud Interrupt.
UART0 Line Control Register (U0LCR)
The U0LCR determines the format of the data character that is to be transmitted or received.
Word Length Select
00 5-bit character length
01 6-bit character length
10 7-bit character length
11 8-bit character length
Stop Bit Select
0 1 stop bit.
1 2 stop bits (1.5 if U0LCR[1:0]=00).
Parity Enable
0 Disable parity generation and checking.
1 Enable parity generation and checking.
Parity Select
00 Odd parity
01 Even Parity
10 Forced "1" stick parity.
11 Forced "0" stick parity.
Break Control
0 Disable break transmission
1 Enable break transmission. Output pin UART0 TXD is forced to logic 0 when
U0LCR[6] is active high.
Divisor Latch Access Bit (DLAB)
0 Disable access to Divisor Latches
1 Enable access to Divisor Latches.
UART0 Line Status Register (U0LSR)
The U0LSR is a read-only register that provides status information on the UART0 TX
and RX blocks.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 99
Receiver Data Ready (RDR) - U0LSR0 is set when the U0RBR holds an unread character and
is cleared when the UART0 RBR FIFO is empty.
0 U0RBR is empty.
1 U0RBR contains valid data.
Overrun Error (OE) - The overrun error condition is set as soon as it occurs. An U0LSR read
clears U0LSR1. U0LSR1 is set when UART0 RSR has a new character assembled and the
UART0 RBR FIFO is full. In this case, the UART0 RBR FIFO will not be overwritten and the
character in the UART0 RSR will be lost.
0 Overrun error status is inactive.
1 Overrun error status is active.
Parity Error (PE) - When the parity bit of a received character is in the wrong state, a parity
error occurs. An U0LSR read clears U0LSR[2]. Time of parity error detection is dependent on
U0FCR[0]. A parity error is associated with the character at the top of the UART0 RBR FIFO.
0 Parity error status is inactive.
1 Parity error status is active.
Framing Error (FE) - When the stop bit of a received character is a logic 0, a framing error
occurs. An U0LSR read clears U0LSR[3]. The time of the framing error detection is dependent
on U0FCR0. Upon detection of a framing error, the Rx will attempt to resynchronize to the data
and assume that the bad stop bit is actually an early start bit. However, it cannot be assumed
that the next received byte will be correct even if there is no Framing Error.
Note: A framing error is associated with the character at the top of the UART0 RBR FIFO.
0 Framing error status is inactive.
1 Framing error status is active.
Break Interrupt (BI) - When RXD0 is held in the spacing state (all 0s) for one full character
transmission (start, data, parity, stop), a break interrupt occurs. Once the break condition has
been detected, the receiver goes idle until RXD0 goes to marking state (all 1s). An U0LSR read
clears this status bit. The time of break detection is dependent on U0FCR[0].
Note: The break interrupt is associated with the character at the top of the UART0 RBR FIFO.
0 Break interrupt status is inactive.
1 Break interrupt status is active.
Transmitter Holding Register Empty (THRE) - THRE is set immediately upon detection of an
empty UART0 THR and is cleared on a U0THR write.
0 U0THR contains valid data.
1 U0THR is empty.
Transmitter Empty (TEMT) - TEMT is set when both U0THR and U0TSR are empty; TEMT is
cleared when either the U0TSR or the U0THR contain valid data.
0 U0THR and/or the U0TSR contains valid data.
1 U0THR and the U0TSR are empty.
Error in RX FIFO (RXFE) - U0LSR[7] is set when a character with a Rx error such as framing
error, parity error or break interrupt, is loaded into the U0RBR. This bit is cleared when the
U0LSR register is read and there are no subsequent errors in the UART0 FIFO.
0 U0RBR contains no UART0 RX errors or U0FCR[0]=0.
1 UART0 RBR contains at least one UART0 RX error.
UART0 Scratch Pad Register (U0SCR), UART0 Auto Baud Generator Register(U0ACR-
controls the process of measuring the incoming clock/data rate for the baud rate generation)
and UART0 Transmit Enable Register (U0TER) are some of the additional registers used for
UART0 operation. UART1 is identical to UART0, with the addition of a modem interface. The
signals additional to RXD1 and TXD1 are CTS1, DCD1, DSR1, DTR1, RI1 and RTS1. The
register organization of UART 1 is
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 100
Name Description Access Reset Value Address
U1RBR
U1THR
U1DLL
U1DLM
U1IER
U1IIR
U1FCR
U1LCR
U1MCR
U1LSR
U1MSR
U1SCR
U1ACR
U1FDR
U1TER
Receiver Buffer Register
Transmit Holding Register
Divisor Latch LSB
Divisor Latch MSB
Interrupt Enable Register
Interrupt ID Reg.
FIFO Control Register
Line Control Register
Modem Ctrl. Reg.
Line Status Register
Modem Status Register
Scratch Pad Reg.
Auto-baud Control Register
Fractional Divider Register
TX. Enable Reg.
RO
WO
R/W
R/W
R/W
RO
WO
R/W
R/W
RO
RO
R/W
R/W
R/W
R/W
NA
NA
0x01
0x00
0x00
0x01
0x00
0x00
0x00
0x60
0x00
0x00
0x00
0x10
0x80
0xE001 0000 (DLAB=0)
0xE001 0000 (DLAB=0)
0xE001 0000 (DLAB=1)
0xE001 0004 (DLAB=1)
0xE001 0004 (DLAB=0)
0xE001 0008
0xE001 0008
0xE001 000C
0xE001 0010
0xE001 0014
0xE001 0018
0xE001 001C
0xE001 0020
0xE001 0028
0xE001 0030
The register description is also identical to UART0 except U1MCR and U1MSR.
UART1 Modem Control Register (U1MCR)
DTR Control - Source for modem output pin, DTR. This bit reads as 0 when modem loopback
mode is active.
RTS Control - Source for modem output pin RTS. This bit reads as 0 when modem loopback
mode is active.
Loopback Mode Select - The modem loopback mode provides a mechanism to perform
diagnostic loopback testing. Serial data from the transmitter is connected internally to serial
input of the receiver. Input pin, RXD1, has no effect on loopback and output pin, TXD1 is held in
marking state. The four modem inputs (CTS, DSR, RI and DCD) are disconnected externally.
Externally, the modem outputs (RTS, DTR) are set inactive. Internally, the four modem outputs
are connected to the four modem inputs. As a result of these connections, the upper four bits of
the U1MSR will be driven by the lower four bits of the U1MCR rather than the four modem
inputs in normal mode. This permits modem status interrupts to be generated in loopback mode
by writing the lower four bits of U1MCR.
0 Disable modem loopback mode
1 Enable modem loopback mode.
RTSen - Auto-RTS control bit.
0 Disable auto-RTS flow control.
1 Enable auto-RTS flow control.
CTSen Auto-CTS control bit.
0 Disable auto-CTS flow control.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 101
1 Enable auto-CTS flow control.
UART1 Modem Status Register (U1MSR)
Delta CTS - Set upon state change of input CTS. Cleared on an U1MSR read.
0 No change detected on modem input, CTS.
1 State change detected on modem input, CTS.
Delta DSR - Set upon state change of input DSR. Cleared on an U1MSR read.
0 No change detected on modem input, DSR.
1 State change detected on modem input, DSR.
Trailing Edge RI - Set upon low to high transition of input RI. Cleared on an U1MSR read.
0 No change detected on modem input, RI.
1 Low-to-high transition detected on RI.
Delta DCD - Set upon state change of input DCD. Cleared on an U1MSR read.
0 No change detected on modem input, DCD.
1 State change detected on modem input, DCD.
CTS - Clear To Send State. Complement of input signal CTS. This bit is connected to
U1MCR[1] in modem loopback mode.
DSR - Data Set Ready State. Complement of input signal DSR. This bit is connected to
U1MCR[0] in modem loopback mode.
RI - Ring Indicator State. Complement of input RI. This bit is connected to U1MCR[2] in modem
loopback mode.
DCD - Data Carrier Detect State. Complement of input DCD. This bit is connected to U1MCR[3]
in modem loopback mode.
The RS232 standard was set long before the advent of the TTL logic family; its input and
output voltage levels are not TTL compatible. In RS232, a logic 1 is represented by -3 to -25 V,
while a logic0 bit is +3 to +25 V, making -3 to +3 undefined, For this reason, to connect any
RS232 to a microcontroller system we must use converters such as MAX232 to convert TTL
Logic levels to the RS232 voltage level, and vice versa. MAX232 IC Chips are commonly
referred to as line drivers.
Fig.14.3: RS232 connector and Interfacing Circuit
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 102
Program Program to send a character through the serial port
#include <iolpc2148.h>
NOP
LDR R0,=VPBDIV
MOV R1,#0X01
STR R1,[R0]
LDR R0,=U0LCR
MOV R1,#0X83
STR R1,[R0]
LDR R0,=U0DLL
MOV R1,#0X4E
STR R1,[R0]
LDR R0,=U0DLM
MOV R1,#0X00
STR R1,[R0]
LDR R0,=U0LCR
MOV R1,#0X03
STR R1,[R0]
LDR R0,=PINSEL0
MOV R1,#0X00000005
STR R1,[R0]
LDR R0,=U0THR
MOV R1,#0X61 //Character a
STR R1,[R0]
CHECK:
LDR R0,=U0LSR
LDR R1,[R0]
MOV R2,#0X20
AND R1,R1,#0X20
CMP R1,R2
BNE CHECK
Programs - Read a byte from serial port at 9600bps. Check the data is either a, b or c and
transfer A,B and C accordingly.
#include "iolpc2148.h"
void delay();
unsigned char a;
void main()
{
VPBDIV = 0x01;
U0LCR = 0x83; //Uart0 Line Control Register, 8-bit data, DLAB=1
U0DLL=0x4E; //U0DLL: UART0 Divisor Latch (LSB),9600 bps
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 103
U0DLM=0x00; //U0DLM: UART0 Divisor Latch (MSB).
U0LCR=0x03; //U0LCR: UART0 Line Control Register
start:
PINSEL0=0x00000004; //Serial port enable
while((U0LSR&0x01)!=0x01); //U0RBR - UART0 Read Buffer Register
a=U0RBR;
if(a==0x61)
{
PINSEL0=0x00000000;
IO0DIR=0x00030000;
IO0PIN=0x00030000;
PINSEL0=0x00000001;
U0THR=0x41;
while((U0LSR&0x20)!=0x20);
delay();
}
else if(a==0x62)
{
PINSEL0=0x00000000;
IO0DIR=0x00030000;
IO0PIN=0x00020000;
PINSEL0=0x00000001;
U0THR=0x42;
while((U0LSR&0x20)!=0x20);
delay();
}
else if(a==0x63)
{
PINSEL0=0x00000000;
IO0DIR=0x00030000;
IO0PIN=0x00010000;
PINSEL0=0x00000001;
U0THR=0x43;
while((U0LSR&0x20)!=0x20);
delay();
}
else
{
PINSEL0=0x00000000;
IO0DIR=0x00030000;
IO0PIN=0x00000000;
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 104
PINSEL0=0x00000001;
U0THR=0x20;
while((U0LSR&0x20)!=0x20);
delay();
}
goto start;
}
void delay()
{
int i;
for(i=0;i<1000;i++);
}
Note:
The routines: getchar(), putchar(), scanf(), printf(), etc. default to the LPC2148 serial port.
Instead of moving the data to U0THR we can simply write putchar(0x30). In the same way
Instead of checking the status of U0LSR and reading the data from U0RBR we can simply write
value=getchar().The scanf function reads data from the input stream using the getchar routine.
Data input are stored in the locations specified by argument. The printf function formats a series
of strings and numeric values and builds a string to write to the output stream using the
putchar function.
Eg: - Program to read 10 numbers from serial port and add the values.
#include "iolpc2148.h"
void delay();
unsigned char input[10];
unsigned long int i,result;
void main()
{
VPBDIV=1; //PCLK=CCLK
U0LCR = 0x83; //DLAB=1,8-data bits
U0DLL = 0x4E;
U0DLM = 0x00; //Set Baudrate as 9600bps
U0LCR = 0x01;
PINSEL0 = 0x00000005; //Enable Transmit line
for(i=0;i<10;i++)
{
input[i]=getchar();
}
result=0;
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 105
for(i=0;i<10;i++)
{
result=result+input[i];
}
printf(The result is %lx,result);
}
Serial port is the simple, Reliable and low-cost data transmission method, which enables
point-to-pint link. Most of the embedded CPUs have inbuilt serial port feature to establish a
connection with other devices. UART1 is identical in operation except the Special Function
Registers.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 106
The LPC2148 microcontroller comes equipped with two timers, each of which may be
controlled, set, read, and configured individually. The Timer/Counter is designed to count cycles
of the peripheral clock (PCLK) or an externally-supplied clock, and can optionally generate
interrupts or perform other actions at specified timer values, based on four match registers. It
also includes four capture inputs to trap the timer value when an input signal transitions,
optionally generating an interrupt. The applications of Timer are
Interval Timer for counting internal events.
Pulse Width Demodulator via Capture inputs.
Free running timer.
LPC2148 has two timers/counters: Timer 0 and Timer 1. Timer/Counter0 and
Timer/Counter1 are functionally identical except for the peripheral base address. The features of
Timers are given below
* A 32-bit Timer/Counter with a programmable 32-bit Prescaler.
* Counter or Timer operation
* Up to four 32-bit capture channels per timer that can take a snapshot of the timer value
when an input signal transitions. A capture event may also optionally generate an interrupt.
* Four 32-bit match registers that allow: Continuous operation with optional interrupt
generation on match, Stop timer on match with optional interrupt generation., Reset timer on
match with optional interrupt generation.
* Up to four external outputs corresponding to match registers, with the following capabilities:
Set low on match.
Set high on match.
Toggle on match.
Do nothing on match.
SFRs Associated with Timer/Counter
Name Description Access Reset Value Address
T0IR
T0TCR
T0TC
T0PR
T0PC
T0MCR
T0MR0
T0MR1
T0MR2
Timer0 Interrupt Register
Timer0 Timer Control Register
Timer0 Timer Counter
Timer0 Prescale Register
Timer0 Prescale Counter
Timer0 Match Control Register
Timer0 Match Register 0
Timer0 Match Register 1
Timer0 Match Register 2
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
0
0
0
0
0
0
0
0
0
0xE000 4000
0xE000 4004
0xE000 4008
0xE000 400C
0xE000 4010
0xE0004014
0xE000 4018
0xE000 401C
0xE000 4020
TIMER
15
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 107
T0MR3
T0CCR
T0CR0
T0CR1
T0CR2
T0CR3
T0EMR
T0CTCR
T1IR
T1TCR
T1TC
T1PR
T1PC
T1MCR
T1MR0
T1MR1
T1MR2
T1MR3
T1CCR
T1CR0
T1CR1
T1CR2
T1CR3
T1EMR
T1CTCR
Timer0 Match Register 3
Timer0 Capture Control Register
Timer0 Capture Register 0
Timer0 Capture Register 1
Timer0 Capture Register 2
Timer0 Capture Register 3
Timer0 External Match Register
Timer0 Count Control Register
Timer1 Interrupt Register
Timer1 Timer Control Register
Timer1 Timer Counter
Timer1 Prescale Register
Timer1 Prescale Counter
Timer1 Match Control Register
Timer1 Match Register 0
Timer1 Match Register 1
Timer1 Match Register 2
Timer1 Match Register 3
Timer1 Capture Control Register
Timer1 Capture Register 0
Timer1 Capture Register 1
Timer1 Capture Register 2
Timer1 Capture Register 3
Timer1 External Match Register
Timer1 Count Control Register
R/W
R/W
RO
RO
RO
RO
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
RO
RO
RO
RO
R/W
R/W
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0xE000 4024
0xE000 4028
0xE000 402C
0xE000 4030
0xE000 4034
0xE000 4038
0xE000 403C
0xE000 4070
0xE000 8000
0xE000 8004
0xE000 8008
0xE000 800C
0xE000 8010
0xE000 8014
0xE000 8018
0xE000 801C
0xE000 8020
0xE000 8024
0xE000 8028
0xE000 802C
0xE000 8030
0xE000 8034
0xE000 8038
0xE000 803C
0xE000 8070
All of the registers associated with Timer, only most important registers are explained in detail.
Interrupt Register (T0IR, T1IR)
The Interrupt Register consists of four bits for the match interrupts and four bits for the
capture interrupts. If an interrupt is generated then the corresponding bit in the IR will be high.
Otherwise, the bit will be low. Writing a logic one to the corresponding IR bit will reset the
interrupt. Writing a zero has no effect.
MR0 Interrupt - Interrupt flag for match channel 0.
MR1 Interrupt - Interrupt flag for match channel 1.
MR2 Interrupt - Interrupt flag for match channel 2.
MR3 Interrupt - Interrupt flag for match channel 3.
CR0 Interrupt - Interrupt flag for capture channel 0 event.
CR1 Interrupt - Interrupt flag for capture channel 1 event.
CR2 Interrupt - Interrupt flag for capture channel 2 event.
CR3 Interrupt - Interrupt flag for capture channel 3 event.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 108
Timer Control Register (T0TCR, T1TCR)
The Timer Control Register is used to control the operation of the Timer/Counter.
Counter Enable - When one, the Timer Counter and Prescale Counter are enabled for
counting. When zero, the counters are disabled.
Counter Reset - When one, the Timer Counter and the Prescale Counter are synchronously
reset on the next positive edge of PCLK. The counters remain reset until TCR[1] is returned to
zero.
Count Control Register (T0CTCR, T1CTCR)
The Count Control Register is used to select between Timer and Counter mode, and in
Counter mode to select the pin and edge(s) for counting.
Counter/Timer Mode - This field selects which rising PCLK edges can increment Timers
Prescale Counter (PC), or clear PC and increment Timer Counter (TC).
00 Timer Mode: every rising PCLK edge
01 Counter Mode: TC is incremented on rising edges on the CAP input selected by
bits 3:2.
10 Counter Mode: TC is incremented on falling edges on the CAP input selected by
bits 3:2.
11 Counter Mode: TC is incremented on both edges on the CAP input selected by
bits 3:2.
Count Input Select - When bits 1:0 in this register are not 00, these bits select which CAP pin
is sampled for clocking:
00 CAPn.0 (CAP0.0 for TIMER0 and CAP1.0 for TIMER1)
01 CAPn.1 (CAP0.1 for TIMER0 and CAP1.1 for TIMER1)
10 CAPn.2 (CAP0.2 for TIMER0 and CAP1.2 for TIMER1)
11 CAPn.3 (CAP0.3 for TIMER0 and CAP1.3 for TIMER1)
Capture Control Register (T0CCR, T1CCR)
The Capture Control Register is used to control whether one of the four Capture
Registers is loaded with the value in the Timer Counter when the capture event occurs, and
whether an interrupt is generated by the capture event. Setting both the rising and falling bits at
the same time is a valid configuration, resulting in a capture event for both edges.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 109
CAP0RE
1 Capture on CAPn.0 rising edge: a sequence of 0 then 1 on CAPn.0 will cause
CR0 to be loaded with the contents of TC.
0 This feature is disabled.
CAP0FE
1 Capture on CAPn.0 falling edge: a sequence of 1 then 0 on CAPn.0 will cause
CR0 to be loaded with the contents of TC.
0 This feature is disabled.
CAP0I
1 Interrupt on CAPn.0 event: a CR0 load due to a CAPn.0 event will generate an
interrupt.
0 This feature is disabled.
CAP1RE
1 Capture on CAPn.1 rising edge: a sequence of 0 then 1 on CAPn.1 will cause
CR1 to be loaded with the contents of TC.
0 This feature is disabled.
CAP1FE
1 Capture on CAPn.1 falling edge: a sequence of 1 then 0 on CAPn.1 will cause
CR1 to be loaded with the contents of TC.
0 This feature is disabled.
CAP1I
1 Interrupt on CAPn.1 event: a CR1 load due to a CAPn.1 event will generate an
interrupt.
0 This feature is disabled.
CAP2RE
1 Capture on CAPn.2 rising edge: A sequence of 0 then 1 on CAPn.2 will cause
CR2 to be loaded with the contents of TC.
0 This feature is disabled.
CAP2FE
1 Capture on CAPn.2 falling edge: a sequence of 1 then 0 on CAPn.2 will cause
CR2 to be loaded with the contents of TC.
0 This feature is disabled.
CAP2I
1 Interrupt on CAPn.2 event: a CR2 load due to a CAPn.2 event will generate an
interrupt.
0 This feature is disabled.
CAP3RE
1 Capture on CAPn.3 rising edge: a sequence of 0 then 1 on CAPn.3 will cause
CR3 to be loaded with the contents of TC.
0 This feature is disabled.
CAP3FE
1 Capture on CAPn.3 falling edge: a sequence of 1 then 0 on CAPn.3 will cause
CR3 be loaded with the contents of TC
0 This feature is disabled.
CAP3I
1 Interrupt on CAPn.3 event: a CR3 load due to a CAPn.3 event will generate an
interrupt.
0 This feature is disabled.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 110
Calculation for the value to be loaded in timer for specified delay
X = Desired delay
Time taken to execute an instruction (Tins)
Tins=No. Of Machine Cycle No. Of Clock cycles for 1 Machine Cycle/Crystal Frequency
Tins=1 3/(12 10
6
) = 0.25 s or 250 ns.
The maximum delay generated by the LPC2148 timer is (FFFFFFFF 250 ns) 1073
seconds without prescaler settings. By using prescaler we can get more and more delays.
For example, the value to be loaded in the timer to generate the delay of 1 second is derived
below.
X = 1s/250ns = 4000000 3(for an instruction) = 12000000(d) = B71B00(h). It means, the timer
is incremented from 00000000h to 00B71B00h for 1 second. Otherwise,
Y=Maximum value to be loaded X
Y = FFFFFFFF(h) B71B00(h) = FF48E4FFh
If the timer is loaded as FF48E4FFh it will take 1 second to overflow (FFFFFFFFh).
Program Send a string timer to the serial port for every 5 seconds.
#include<IOLPC2148.h>
#include<stdio.h>
void main()
{
while(1)
{
VPBDIV=0X01; //VLSI Peripheral Bus in same frequency
U0LCR=0X83; // Enables the divisor latch bit and 8 bit data
U0DLL=0X4E; //UART Divisor Latch LSB
U0DLM=0X00; //UART Divisor Latch MSB
U0LCR=0X03; // Enables the divisor latch bit.
PINSEL0=0X00000005;//Pin function Select'0', to set the transmit bit
loop:
T0TC=0;
T0PR=0;
T0TCR=1;
rept:
if(T0TC<=0X03938700)
goto rept;
printf("timer") ;
goto loop;
}
}
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 111
In computing world, an interrupt is an asynchronous signal from hardware indicating the
need for attention or a synchronous event in software indicating the need for a change in
execution. As the name implies, an interrupt is some event, which interrupts normal program
execution.
As stated earlier, program flow is always sequential, being altered only by those
instructions, which expressly cause program flow to deviate in some way. However, interrupts
give us a mechanism to "put on hold" the normal program flow, execute a subroutine, and then
resume normal program flow as if we had never left it. This subroutine, called an interrupt
handler (Interrupt service Routine), is only executed when a certain event (interrupt) occurs. The
event may be one of the timers "overflowing," receiving a character via the serial port,
transmitting a character via the serial port, or one of two "external events." The LPC2148 has
Vectored Interrupt Controller. The Vectored Interrupt Controller (VIC) takes 32 interrupt request
inputs and programmably assigns them into 3 categories, FIQ, vectored IRQ, and non-vectored
IRQ. The programmable assignment scheme means that priorities of interrupts from the various
peripherals can be dynamically assigned and adjusted.
Fast Interrupt reQuest (FIQ) requests have the highest priority. If more than one request
is assigned to FIQ, the VIC ORs the requests to produce the FIQ signal to the ARM processor.
The fastest possible FIQ latency is achieved when only one request is classified as FIQ,
because then the FIQ service routine can simply start dealing with that device. But if more than
one request is assigned to the FIQ class, the FIQ service routine can read a word from the VIC
that identifies which FIQ source(s) is (are) requesting an interrupt. Vectored IRQs have the
middle priority, but only 16 of the 32 requests can be assigned to this category. Any of the 32
INTERRUPTS
16
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 112
requests can be assigned to any of the 16 vectored IRQ slots, among which slot 0 has the
highest priority and slot 15 has the lowest. Non-vectored IRQs have the lowest priority.
The VIC ORs the requests from all the vectored and non-vectored IRQs to produce the
IRQ signal to the ARM processor. The IRQ service routine can start by reading a register from
the VIC and jumping there. If any of the vectored IRQs are requesting, the VIC provides the
address of the highest-priority requesting IRQs service routine, otherwise it provides the
address of a default routine that is shared by all the non-vectored IRQs. The default routine can
read another VIC register to see what IRQs are active. All registers in the VIC are word
registers. Byte and halfword reads and write are not supported.
SFRs Associated with Interrupts
Name Description Access Reset Value Address
VICIRQStatus
VICFIQStatus
VICRawIntr
VICIntSelect
VICIntEnable
VICIntEnClr
VICSoftInt
VICSoftIntClear
VICProtection
VICVectAddr
VICDefVectAddr
VICVectAddr0
VICVectAddr1
VICVectAddr2
VICVectAddr3
VICVectAddr4
VICVectAddr5
VICVectAddr6
VICVectAddr7
VICVectAddr8
VICVectAddr9
VICVectAddr10
VICVectAddr11
VICVectAddr12
VICVectAddr13
VICVectAddr14
VICVectAddr15
VICVectCntl0
VICVectCntl1
VICVectCntl2
VICVectCntl3
VICVectCntl4
VICVectCntl5
IRQ Status Register.
FIQ Status Requests.
Raw Interrupt Status Register.
Interrupt Select Register.
Interrupt Enable Register
Interrupt Enable Clear Register.
Software Interrupt Register.
Software Interrupt Clear Register.
Protection enable register.
Vector Address Register.
Default Vector Address Register.
Vector address 0 register.
Vector address 1 register.
Vector address 2 register.
Vector address 3 register.
Vector address 4 register.
Vector address 5 register.
Vector address 6 register.
Vector address 7 register.
Vector address 8 register.
Vector address 9 register.
Vector address 10 register.
Vector address 11 register.
Vector address 12 register.
Vector address 13 register.
Vector address 14 register.
Vector address 15 register.
Vector control 0 register.
Vector control 1 register.
Vector control 2 register.
Vector control 3 register.
Vector control 4 register.
Vector control 5 register.
RO
RO
RO
R/W
R/W
WO
R/W
WO
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0xFFFF F000
0xFFFF F004
0xFFFF F008
0xFFFF F00C
0xFFFF F010
0xFFFF F014
0xFFFF F018
0xFFFF F01C
0xFFFF F020
0xFFFF F030
0xFFFF F034
0xFFFF F100
0xFFFF F104
0xFFFF F108
0xFFFF F10C
0xFFFF F110
0xFFFF F114
0xFFFF F118
0xFFFF F11C
0xFFFF F120
0xFFFF F124
0xFFFF F128
0xFFFF F12C
0xFFFF F130
0xFFFF F134
0xFFFF F138
0xFFFF F13C
0xFFFF F200
0xFFFF F204
0xFFFF F208
0xFFFF F20C
0xFFFF F210
0xFFFF F214
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 113
VICVectCntl6
VICVectCntl7
VICVectCntl8
VICVectCntl9
VICVectCntl10
VICVectCntl11
VICVectCntl12
VICVectCntl13
VICVectCntl14
VICVectCntl15
Vector control 6 register.
Vector control 7 register.
Vector control 8 register.
Vector control 9 register.
Vector control 10 register.
Vector control 11 register.
Vector control 12 register.
Vector control 13 register.
Vector control 14 register.
Vector control 15 register.
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
R/W
0
0
0
0
0
0
0
0
0
0
0xFFFF F218
0xFFFF F21C
0xFFFF F220
0xFFFF F224
0xFFFF F228
0xFFFF F22C
0xFFFF F230
0xFFFF F234
0xFFFF F238
0xFFFF F23C
The ability to interrupt normal program execution when certain events occur makes it
much easier and much more efficient to handle certain conditions. If it were not for interrupts we
would have to manually check in our main program whether the timers had over flown, whether
we had received another character via the serial port, or if some external event had occurred.
Besides making the main program ugly and hard to read, such a situation would make our
program inefficient since wed be burning precious "instruction cycles" checking for events that
usually dont happen.
Interrupt Sources
Block Flag(s)
WDT
-
ARM Core
ARM Core
TIMER0
TIMER1
UART0
UART1
PWM0
I
2
C0
SPI0
SPI1 (SSP)
Watchdog Interrupt (WDINT)
Reserved for Software Interrupts only
Embedded ICE, DbgCommRx
Embedded ICE, DbgCommTX
Match 0 - 3 (MR0, MR1, MR2, MR3)
Capture 0 - 3 (CR0, CR1, CR2, CR3)
Match 0 - 3 (MR0, MR1, MR2, MR3)
Capture 0 - 3 (CR0, CR1, CR2, CR3)
Rx Line Status (RLS)
Transmit Holding Register Empty (THRE)
Rx Data Available (RDA)
Character Time-out Indicator (CTI)
Rx Line Status (RLS)
Transmit Holding Register Empty (THRE)
Rx Data Available (RDA)
Character Time-out Indicator (CTI)
Modem Status Interrupt (MSI)
Match 0 - 6 (MR0, MR1, MR2, MR3, MR4, MR5, MR6)
SI (state change)
SPI Interrupt Flag (SPIF)
Mode Fault (MODF)
TX FIFO at least half empty (TXRIS)
Rx FIFO at least half full (RXRIS)
Receive Timeout condition (RTRIS)
Receive overrun (RORRIS)
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 114
PLL
RTC
System Control
ADC0
I
2
C1
BOD
ADC1
USB
PLL Lock (PLOCK)
Counter Increment (RTCCIF)
Alarm (RTCALF)
External Interrupt 0 (EINT0)
External Interrupt 1 (EINT1)
External Interrupt 2 (EINT2)
External Interrupt 3 (EINT3)
A/D Converter 0 end of conversion
SI (state change)
Brown Out detect
A/D Converter 1 end of conversion
USB interrupts, DMA interrupt
The structure of the interrupt registers is given below.
Software Interrupt register
0 Do not force the interrupt request with this bit number.
1 Force the interrupt request with this bit number.
Software Interrupt Clear register
0 Writing a 0 leaves the corresponding bit in VICSoftInt unchanged.
1 Writing a 1 clears the corresponding bit in the Software Interrupt register, thus
releasing the forcing of this request.
Raw Interrupt status register
0 The interrupt request or software interrupt with this bit number is negated.
1 The interrupt request or software interrupt with this bit number is negated.
Interrupt Enable register
When this register is read, 1s indicate interrupt requests or software interrupts that are enabled
to contribute to FIQ or IRQ.
Interrupt Enable Clear register
0 Writing a 0 leaves the corresponding bit in VICIntEnable unchanged.
1 Writing a 1 clears the corresponding bit in the Interrupt Enable register, thus
disabling interrupts for this request.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 115
Interrupt Select register
0 The interrupt request with this bit number is assigned to the IRQ category.
1 The interrupt request with this bit number is assigned to the FIQ category.
IRQ Status register
A bit read as 1 indicates a corresponding interrupt request being enabled, classified as IRQ, and
asserted
FIQ Status register
A bit read as 1 indicates a corresponding interrupt request being enabled, classified as FIQ, and
asserted
Vector Control registers 0-15
These are a read/write accessible registers. Each of these registers controls one of the
16 vectored IRQ slots. Slot 0 has the highest priority and slot 15 the lowest. Note that disabling
a vectored IRQ slot in one of the VICVectCntl registers does not disable the interrupt itself, the
interrupt is simply changed to the non-vectored form.
int_request/sw_int_assig - The number of the interrupt request or software interrupt assigned
to this vectored IRQ slot. As a matter of good programming practice, software should not assign
the same interrupt number to more than one enabled vectored IRQ slot. But if this does occur,
the lower numbered slot will be used when the interrupt request or software interrupt is enabled,
classified as IRQ, and asserted.
IRQslot_en - When 1, this vectored IRQ slot is enabled, and can produce a unique ISR address
when its assigned interrupt request or software interrupt is enabled, classified as IRQ, and
asserted.
Vector Address registers 0-15
These are a read/write accessible registers. These registers hold the addresses of the Interrupt
Service routines (ISRs) for the 16 vectored IRQ slots.
Default Vector Address register
This is a read/write accessible register. This register holds the address of the Interrupt Service
routine (ISR) for non-vectored IRQs.
Vector Address register
This is a read/write accessible register. When an IRQ interrupt occurs, the IRQ service routine
can read this register and jump to the value read.
Protection Enable register
This is a read/write accessible register. It controls access to the VIC registers by software
running in User mode.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 116
Program Use external interrupts to show the function of interrupts
#include "iolpc2148.h"
#include "intrinsics.h"
#define int0en IO0DIR_bit.P0_16
#define int1en IO0DIR_bit.P0_3
#define int2en IO0DIR_bit.P0_15
void printf(unsigned char array[]);
void intenable();
void int0(void);
void int1(void);
void int2(void);
void main()
{
VPBDIV = 0x01;
U0LCR = 0x83;
U0DLL=0x4E;
U0DLM=0x00;
U0LCR=0x03;
intenable();
while(1)
{
printf("Normal Routine ");
}
}
void printf(unsigned char array[])
{
int i;
for(i=0;array[i]!='\0';i++)
{
PINSEL0=0x00000001;
U0THR=array[i];
while((U0LSR&0x20)!=0x20);
}
}
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 117
void intenable()
{
PINSEL1_bit.P0_16=0x01;
PINSEL0_bit.P0_3=0x3;
PINSEL0_bit.P0_15=0x02;
int0en=0;
int1en=0;
int2en=0;
VICIntSelect &= ~(1<<VIC_EINT0); //Select the interrupt
VICVectAddr0 = (unsigned int)&int0;
VICVectCntl0 = 0x20 | VIC_EINT0;
VICIntEnable |= (1<<VIC_EINT0);
VICIntSelect &= ~(1<<VIC_EINT1); //Select the interrupt
VICVectAddr1 = (unsigned int)&int1;
VICVectCntl1 = 0x20 | VIC_EINT1;
VICIntEnable |= (1<<VIC_EINT1);
VICIntSelect &= ~(1<<VIC_EINT2); // IRQ on external int 2.
VICVectAddr2 = (unsigned int)&int2; // Install EINT2 in VIC addr slot
VICVectCntl2 = 0x20 | VIC_EINT2; // Enable vect int for EINT2.
VICIntEnable |= (1<<VIC_EINT2); // Enable EINT 2 interrupt.
__enable_interrupt(); // Global interrupt enable
}
#pragma vector=0x18
__irq __arm void IRQ_ISR_Handler (void)
{
void (*interrupt_function)();
unsigned int vector;
vector = VICVectAddr;
interrupt_function = (void(*)())vector;
(*interrupt_function)();
VICVectAddr = 0;
}
void int0(void)
{
EXTINT_bit.EINT0 = 1;
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 118
if(!EXTINT_bit.EINT0)
{
printf("Interrupt 0 ");
}
}
void int1(void)
{
EXTINT_bit.EINT1 = 1; // Try to reset external interrupt flag.
if(!EXTINT_bit.EINT1) // Check if flag was reset (button not pressed).
{
printf("Interrupt 1 ");
}
}
void int2(void)
{
EXTINT_bit.EINT2 = 1; // Try to reset external interrupt flag.
if(!EXTINT_bit.EINT2) // Check if flag was reset (button not pressed).
{
printf("Interrupt 2 ");
}
}
Program Send a character * to the serial port regularly and for every specified delay
send a character # to the serial port. Use timer interrupt.
#include<iolpc2148.h>
#include"intrinsics.h"
#include<stdio.h>
void TIMER0_ISR(void);
void main()
{
VPBDIV=0x01; //Set Baudrate as 9600bps
U0LCR=0x83;
U0DLL=0x4E;
U0DLM=0x00;
U0LCR=0x03;
PINSEL0=0x00000005;
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 119
T0IR=0xFF; // reset match and capture event interrupts
T0TC=0; // Clear timer counter
T0PR= 0; // No Prescalar
T0MR0=0x07270E00 ;
T0MCR = 3; // Reset Timer Counter & Interrupt on match
T0TCR = 1; // Counting enable
VICIntSelect &= ~(1<<VIC_TIMER0); // Timer 0 intrpt is an IRQ (VIC_TIMER0 = 4)
VICVectAddr0 = (unsigned int) & TIMER0_ISR; // Install ISR in VIC addr slot 0
VICVectCntl0 = 0x20 | VIC_TIMER0; // IRQ type, TIMER 0 int enabled
VICIntEnable |= (1<<VIC_TIMER0); // Turn on Timer0 Interrupt
__enable_interrupt();
while(1)
{
printf("*");
}
}
#pragma vector=0x18
__irq __arm void IRQ_ISR_Handler (void)
{
void (*interrupt_function)();
unsigned int vector;
static unsigned int us_count;
us_count++;
vector = VICVectAddr; // Get interrupt vector.
interrupt_function = (void(*)())vector; // Call MM_TIMER0_ISR thru pointer
(*interrupt_function)(); // Call vectored interrupt function
VICVectAddr = 0; // Clear interrupt in VIC
}
void TIMER0_ISR(void)
{
printf("#");
T0TC=0;
T0IR = 1; // Clear timer interrupt
}
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 120
int putchar(int c)
{
U0THR =c;
while((U0LSR&0x20)!=0x20);
return c;
}
Program - Blink the LED normally and if there is an interrupt occurred through serial
port switch on the other LED to indicate that the interrupt has occurred
#include "iolpc2148.h"
#include "intrinsics.h"
void SerialISR(void);
void delay();
unsigned char s;
void main()
{
VPBDIV=1; //PCLK=CCLK
U0LCR = 0x83; //DLAB=1,8-data bits
U0DLL = 0x4E;
U0DLM = 0x00; //Set Baudrate as 9600bps
U0LCR = 0x01;
U0IER = 0x00000001; //UART0 Interrupt Enable Register
PINSEL0 = 0x00000005; //Enable Transmit line
VICIntSelect &= ~(1<<VIC_UART0); //Select the interrupt
VICVectAddr0 = (unsigned int)&SerialISR;
VICVectCntl0 = 0x20 | VIC_UART0;
VICIntEnable |= (1<<VIC_UART0);
__enable_interrupt(); //Enable Global Interrupts
while(1)
{
IO0DIR=0x00030000;
IO0SET=0x00030000;
delay();
IO0CLR=0x00030000;
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 121
delay();
}
}
void SerialISR(void)
{
s=U0RBR;
IO0DIR=0x00030000;
IO0SET=0x00010000;
IO0CLR=0x00020000;
delay();
}
void delay()
{
int m,n;
for(m=0;m<100;m++)
{
for(n=0;n<1000;n++);
}
}
#pragma vector=0x18
__irq __arm void IRQ_ISR_Handler (void)
{
void (*interrupt_function)();
unsigned int vector;
vector = VICVectAddr;
interrupt_function = (void(*)())vector;
(*interrupt_function)();
VICVectAddr = 0;
}
Interrupts are used to ensure adequate service response times by the processing.
Sometimes, with software polling routines, service times by the processor cannot be
guaranteed, and data may be lost. The use of interrupts guarantees that the processor will
service the request within a specified time period, reducing the likelihood of lost data.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 122
Most of the signals directly encountered in science and engineering are continuous: light
intensity that changes with distance; voltage that varies over time; a chemical reaction rate that
depends on temperature, etc. Analog-to-Digital Conversion (ADC) and Digital-to-Analog
Conversion (DAC) are the processes that allow digital computers to interact with these everyday
signals. Digital information is different from its continuous counterpart in two important respects:
it is sampled, and it is quantized. Digital systems are designed to store, process, and
communicate information in digital form. A digital system uses discrete (that is, discontinuous)
values to represent information for input, processing, transmission, storage, etc. The word
digital comes from the same source as the word digit and digitus (the Latin word for finger), as
fingers are used for discrete counting.
Digital Vs Analog
Analog signals were used in conjunction with copper telephone lines to transmit
conversations. This involved using 2 conductors for each line (send and receive). As technology
progressed an increasing number of people started using the telephone making analog signals
too expensive and troublesome to maintain. The pictures given below show the analog and
digital waveforms.
Fig. 17.1: Analog Vs Digital Waveforms
The X and Y lines represent the maximum voltage capacity for the signal to travel
clearly. The signal level crosses over the X and Y limits and has now become degraded and
hard for the device on the receiving end to interpret. The signals above and below X and Y lines
are called as Noise. Certain factors will add more "noise" to the signal are air conditioning
units, fluorescent lights, magnetic fields, etc. There are methods of separating or "filtering" noise
from analog signals. However, most of these methods are not accurate, or are devices that
transform the signals from analog to digital and back to analog. For these reasons, the use of
digital signaling is used to provide a better delivery method. Since the digital signal is very
uniform, noise has not severely altered its shape or amplitude. The digital signal shows a far
less change to the actual waveform than the previous analog signal. Computers use digital
signals to send and receive data. Although digital signals can only be in the state 1 (on) and 0
(off), complicated combinations of these two values are used to send/receive data.
ANALOG TO DIGITAL CONVERTER (ADC)
17
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 123
Analog to Digital Converter (ADC)
Analog to Digital converter (ADC) is a device that converts continuously varying analog
signals from instruments that monitor such conditions as movement, temperature, sound, etc.,
into binary code for the computer. It may be contained on a single chip or can be one circuit
within a chip. Analog to Digital conversion is the process of changing continuously varying data,
such as voltage, current, or shaft rotation, into discrete digital quantities that represent the
magnitude of the data compared to a standard or reference at the moment the conversion is
made. According to the method of conversion ADCs can be classified into Direct-Conversion
ADCs, Successive Approximation ADCs, Integrating ADC and Sigma-Delta ADCs.
Direct-conversion ADCs: Direct conversion is also known as a flash conversion. ADCs based
on this architecture are extremely fast with a sampling rate of up to 1GHz. However, their
resolution is limited because of the large number of comparators and reference voltages
required. The input signal is fed simultaneously to all comparators. A priority encoder generates
a digital output that corresponds with the highest activated comparator. The identity of
comparators is important; any mismatch can cause a static error. Flash ADCs have a short
aperture interval - the time when the comparators' outputs are latched.
Fig. 17.2: Direct Conversion ADC
Successive approximation ADCs: The conversion technique based on a successive-
approximation register (SAR), also known as bit-weighing conversion, employs a comparator to
weigh the applied input voltage against the output of an N-bit digital-to-analog converter (DAC).
Using the DAC output as a reference, this process approaches the final result as a sum of N
weighting steps, in which each step is a single-bit conversion. Initially all bits of SAR are set to
0. Then, beginning with the most significant bit, each bit is set to 1 sequentially. If the DAC
output does not exceed the input signal voltage, the bit is left as a 1. Otherwise it is set back to
0. It is kind of a binary search. For an n-bit ADC, n steps are required. SAR converters sample
at rates to 1Msps, draw low supply current, and offer the lowest production cost.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 124
Fig. 17.3: Successive approximation ADC
Integrating ADCs: A classical dual-slope converter is shown at the drawing. A current,
proportional to the input voltage, charges a capacitor for a fixed time interval T
charge
. At the end
of this interval the device resets its counter and applies an opposite-polarity (negative) reference
voltage to the integrator input. With this opposite-polarity signal applied the cap is discharged by
a constant current until the voltage at the output of the integrator reaches zero again. The time
T
discharge
is proportional to the input voltage level and used to enable a counter. The final count
provides the digital output, corresponding to the input level.
Fig. 17.4: Integrating ADC
Integrating ADCs are extremely slow devices with low input bandwidths. But their ability to reject
high-frequency noise and fixed low frequencies such as 50Hz or 60Hz makes them useful in
noisy industrial environments and applications. Provide 10-18 bit resolution. A conversion time
for a medium speed 12 bit integrating ADC is about 20mS. This type of ADC is most commonly
used in multi-meters.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 125
Sigma-delta ADCs: Sigma-delta converters, also called oversampling converters, consist of 2
major blocks: modulator and digital filter.
Fig.17.5: Sigma-Delta ADC
The modulator, whose architecture is similar to that of a dual-slope ADC, includes an integrator
and a comparator with a feedback loop that contains a 1-bit DAC. The modulator oversamples
the signal, transforming it to a serial bit stream with a frequency well above the required
sampling rate. The output filter then converts the bit stream to a sequence of parallel digital
words at the sampling rate. The delta-sigma converters perform high-speed, low resolution (1-
bit) A/D conversions, and then remove the resulting high-level quantization noise by passing the
signal through analog and digital filters. Features: high resolution, high accuracy, low noise, low
cost. Good for applications with a bandwidth up to 1MHz, such as speech, audio.
The LPC 2148 has 10-bit successive approximation analog to digital converter. Basic
clocking for the A/D converters is provided by the VPB clock. A programmable divider is
included in each converter, to scale this clock to the 4.5 MHz (max) clock needed by the
successive approximation process. A fully accurate conversion requires 11 of these clocks. The
ADC cell can measure the voltage on any of the ADC input signals. Note that these analog
inputs are always connected to their pins, even if the Pin function Select register assigns them
to port pins. A simple self-test of the ADC can be done by driving these pins as port outputs.
While the ADC pins are specified as 5 V tolerant More than 3.3 V (VDDA) +10 % should
not be applied to any pin that is selected as an ADC input, or the ADC reading will be incorrect.
If for example AD0.0 and AD0.1 are used as the ADC0 inputs and voltage on AD0.0 = 4.5 V
while AD0.1 = 2.5 V, an excessive voltage on the AD0.0 can cause an incorrect reading of the
AD0.1, although the AD0.1 input voltage is within the right range.
SFRs Associated with ADC
Name Description Access Reset Value Address
AD0CR
AD1CR
AD0GDR
A/D 0 Control Register
A/D 1 Control Register
A/D 0 Global Data Register
R/W
R/W
R/W
0x0000 0001
0x0000 0001
NA
0xE003 4000
0xE006 0000
0xE003 4004
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 126
AD1GDR
AD0STAT
AD1STAT
ADGSR
AD0INTEN
AD1INTEN
AD0DR0
AD1DR0
AD0DR1
AD1DR1
AD0DR2
AD1DR2
AD0DR3
AD1DR3
AD0DR4
AD1DR4
AD0DR5
AD1DR5
AD0DR6
AD1DR6
AD0DR7
AD1DR7
A/D 1 Global Data Register
A/D 0 Status Register
A/D 1 Status Register
A/D Global Start Register
A/D 0 Interrupt Enable Register
A/D 1 Interrupt Enable Register
A/D 0 Channel 0 Data Register
A/D 1 Channel 0 Data Register
A/D 0 Channel 1 Data Register
A/D 1 Channel 1 Data Register
A/D 0 Channel 2 Data Register
A/D 1 Channel 2 Data Register
A/D 0 Channel 3 Data Register
A/D 1 Channel 3 Data Register
A/D 0 Channel 4 Data Register
A/D 1 Channel 4 Data Register
A/D 0 Channel 5 Data Register
A/D 1 Channel 5 Data Register
A/D 0 Channel 6 Data Register
A/D 1 Channel 6 Data Register
A/D 0 Channel 7 Data Register
A/D 1 Channel 7 Data Register
R/W
RO
RO
WO
R/W
R/W
RO
RO
RO
RO
RO
RO
RO
RO
RO
RO
RO
RO
RO
RO
RO
RO
NA
0x0000 0000
0x0000 0000
0x00
0x0000 0100
0x0000 0100
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
NA
0xE006 0004
0xE003 4030
0xE006 0030
0xE003 4008
0xE003 400C
0xE006 000C
0xE003 4010
0xE006 0010
0xE003 4014
0xE006 0014
0xE003 4018
0xE006 0018
0xE003 401C
0xE006 001C
0xE003 4020
0xE006 0020
0xE003 4024
0xE006 0024
0xE003 4028
0xE006 0028
0xE003 402C
0xE006 002C
ADC Control register (AD0CR, AD1CR)
SEL - Selects which of the AD0.7:0/AD1.7:0 pins is (are) to be sampled and converted. For
AD0, bit 0 selects Pin AD0.0, and bit 7 selects pin AD0.7.
CLKDIV - The VPB clock (PCLK) is divided by (this value plus one) to produce the clock for the
A/D converter, which should be less than or equal to 4.5 MHz. Typically, software should
program the smallest value in this field that yields a clock of 4.5 MHz or slightly less.
BURST
1 The AD converter does repeated conversions at the rate selected by the CLKS field,
scanning (if necessary) through the pins selected by 1s in the SEL field. The first
conversion after the start corresponds to the least-significant 1 in the SEL field, then
higher numbered 1-bits (pins) if applicable. Repeated conversions can be terminated by
clearing this bit, but the conversion thats in progress when this bit is cleared will be
completed.
(Important: START bits must be 000 when BURST = 1 or conversions will not start.)
0 Conversions are software controlled and require 11 clocks.
CLKS - This field selects the number of clocks used for each conversion in Burst mode, and the
number of bits of accuracy of the result in the RESULT bits of ADDR, between 11 clocks (10
bits) and 4 clocks (3 bits).
000 11 clocks / 10 bits
001 10 clocks / 9bits
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 127
010 9 clocks / 8 bits
011 8 clocks / 7 bits
100 7 clocks / 6 bits
101 6 clocks / 5 bits
110 5 clocks / 4 bits
111 4 clocks / 3 bits
PDN
1 The A/D converter is operational.
0 The A/D converter is in power-down mode.
START - When the BURST bit is 0, these bits control whether and when an A/D conversion is
started:
000 No start (this value should be used when clearing PDN to 0).
001 Start conversion now.
010 Start conversion when the edge selected by bit 27 occurs on P0.16 pin.
011 Start conversion when the edge selected by bit 27 occurs on P0.22 pin.
100 Start conversion when the edge selected by bit 27 occurs on MAT0.1.
101 Start conversion when the edge selected by bit 27 occurs on MAT0.3.
110 Start conversion when the edge selected by bit 27 occurs on MAT1.0.
111 Start conversion when the edge selected by bit 27 occurs on MAT1.1.
EDGE - This bit is significant only when the START field contains 010-111. In these cases:
1 Start conversion on a falling edge on the selected CAP/MAT signal.
0 Start conversion on a rising edge on the selected CAP/MAT signal.
ADC Global Data Register (AD0GDR, AD1GDR)
RESULT - When DONE is 1, this field contains a binary fraction representing the voltage on the
Ain pin selected by the SEL field, divided by the voltage on the VDDA pin (V/VREF). Zero in the
field indicates that the voltage on the Ain pin was less than, equal to, or close to that on V
SSA
,
while 0x3FF indicates that the voltage on Ain was close to, equal to, or greater than that on
V
REF
.
CHN - These bits contain the channel from which the RESULT bits were converted (e.g. 000
identifies channel 0, 001 channel 1...).
OVERUN - This bit is 1 in burst mode if the results of one or more conversions was (were) lost
and overwritten before the conversion that produced the result in the RESULT bits. This bit is
cleared by reading this register.
DONE - This bit is set to 1 when an A/D conversion completes. It is cleared when this register is
read and when the ADCR is written. If the ADCR is written while a conversion is still in progress,
this bit is set and a new conversion is started.
ADC Global Start Register (ADGSR)
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 128
BURST
1 The AD converters do repeated conversions at the rate selected by their CLKS fields,
scanning (if necessary) through the pins selected by 1s in their SEL field. The first
conversion after the start corresponds to the least-significant 1 in the SEL field, then
higher numbered 1-bits (pins) if applicable. Repeated conversions can be terminated by
clearing this bit, but the conversion thats in progress when this bit is cleared will be
completed.
Important: START bits must be 000 when BURST = 1 or conversions will not start.
0 Conversions are software controlled and require 11 clocks.
START - When the BURST bit is 0, these bits control whether and when an A/D conversion is
started:
000 No start (this value should be used when clearing PDN to 0).
001 Start conversion now.
010 Start conversion when the edge selected by bit 27 occurs on P0.16 pin.
011 Start conversion when the edge selected by bit 27 occurs on P0.22 pin.
100 Start conversion when the edge selected by bit 27 occurs on MAT0.1.
101 Start conversion when the edge selected by bit 27 occurs on MAT0.3.
110 Start conversion when the edge selected by bit 27 occurs on MAT1.0.
111 Start conversion when the edge selected by bit 27 occurs on MAT1.1.
EDGE - This bit is significant only when the START field contains 010-111. In these cases:
1 Start conversion on a falling edge on the selected CAP/MAT signal.
0 Start conversion on a rising edge on the selected CAP/MAT signal.
ADC Status Register (AD0STAT, AD1STAT)
The A/D Status register allows checking the status of all A/D channels simultaneously.
DONE0 - This bit mirrors the DONE status flag from the result register for A/D channel 0.
DONE1 - This bit mirrors the DONE status flag from the result register for A/D channel 1.
DONE2 - This bit mirrors the DONE status flag from the result register for A/D channel 2.
DONE3 - This bit mirrors the DONE status flag from the result register for A/D channel 3.
DONE4 - This bit mirrors the DONE status flag from the result register for A/D channel 4.
DONE5 - This bit mirrors the DONE status flag from the result register for A/D channel 5.
DONE6 - This bit mirrors the DONE status flag from the result register for A/D channel 6.
DONE7 - This bit mirrors the DONE status flag from the result register for A/D channel 7.
OVERRUN0 - This bit mirrors the OVERRRUN status flag from the result register for A/D
channel 0.
OVERRUN1 - This bit mirrors the OVERRRUN status flag from the result register for A/D
channel 1.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 129
OVERRUN2 - This bit mirrors the OVERRRUN status flag from the result register for A/D
channel 2.
OVERRUN3 - This bit mirrors the OVERRRUN status flag from the result register for A/D
channel 3.
OVERRUN4 - This bit mirrors the OVERRRUN status flag from the result register for A/D
channel 4.
OVERRUN5 - This bit mirrors the OVERRRUN status flag from the result register for A/D
channel 5.
OVERRUN6 - This bit mirrors the OVERRRUN status flag from the result register for A/D
channel 6.
OVERRUN7 - This bit mirrors the OVERRRUN status flag from the result register for A/D
channel 7.
ADINT - This bit is the A/D interrupt flag. It is one when any of the individual A/D channel Done
flags is asserted and enabled to contribute to the A/D interrupt via the ADINTEN register.
A/D Interrupt Enable Register (AD0INTEN, AD1INTEN)
This register allows control over which A/D channels generate an interrupt when a conversion is
complete.
ADINTEN0
0 Completion of a conversion on ADC channel 0 will not generate an interrupt.
1 Completion of a conversion on ADC channel 0 will generate an interrupt.
ADINTEN1
0 Completion of a conversion on ADC channel 1 will not generate an interrupt.
1 Completion of a conversion on ADC channel 1 will generate an interrupt.
ADINTEN2
0 Completion of a conversion on ADC channel 2 will not generate an interrupt.
1 Completion of a conversion on ADC channel 2 will generate an interrupt.
ADINTEN3
0 Completion of a conversion on ADC channel 3 will not generate an interrupt.
1 Completion of a conversion on ADC channel 3 will generate an interrupt.
ADINTEN4
0 Completion of a conversion on ADC channel 4 will not generate an interrupt.
1 Completion of a conversion on ADC channel 4 will generate an interrupt.
ADINTEN5
0 Completion of a conversion on ADC channel 5 will not generate an interrupt.
1 Completion of a conversion on ADC channel 5 will generate an interrupt.
ADINTEN6
0 Completion of a conversion on ADC channel 6 will not generate an interrupt.
1 Completion of a conversion on ADC channel 6 will generate an interrupt.
ADINTEN7
0 Completion of a conversion on ADC channel 7 will not generate an interrupt.
1 Completion of a conversion on ADC channel 7 will generate an interrupt.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 130
ADGINTEN
0 Only the individual ADC channels enabled by ADINTEN7:0 will generate interrupts.
1 Only the global DONE flag in ADDR is enabled to generate an interrupt.
A/D Data Registers (AD0DR0 to AD0DR7 and AD1DR0 to AD1DR7)
The A/D Data Register hold the result when an A/D conversion is complete, and also include the
flags that indicate when a conversion has been completed and when a conversion overrun has
occurred.
RESULT - When DONE is 1, this field contains a binary fraction representing the voltage on the
AIN pin, divided by the voltage on the VREF pin (V/VREF). Zero in the field indicates that the
voltage on the AIN pin was less than, equal to, or close to that on VSSA, while 0x3FF indicates
that the voltage on AIN was close to, equal to, or greater than that on VREF.
OVERRUN - This bit is 1 in burst mode if the results of one or more conversions was (were) lost
and overwritten before the conversion that produced the result in the RESULT bits. This bit is
cleared by reading this register.
DONE - This bit is set to 1 when an A/D conversion completes. It is cleared when this register is
read.
Program Convert the Analog value interfaced with channel 1 and 2 into digital and
display the result in the serial port
#include "iolpc2148.h"
#include<stdio.h>
void delay();
long int ADC1,ADC2;
void main()
{
VPBDIV = 0x01;
U0LCR = 0x83; //Uart0 Line Control Register, 8-bit data, DLAB=1
U0DLL=0x4E; //U0DLL: UART0 Divisor Latch (LSB),9600 bps
U0DLM=0x00; //U0DLM: UART0 Divisor Latch (MSB).
U0LCR=0x03;
PINSEL0=0x00000005;
PINSEL1=0x05000000; //Select P0.28 as AD0.1
AD0CR_bit.CLKDIV = 0x02; //This value loaded to select the clock for A/D.
(1200000/(2+1) must be less than 4.5 MHz)
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 131
AD0CR_bit.BURST = 1; //Enable Repeated Conversion
AD0CR_bit.CLKS = 0; //11 clocks/10 bit accuracy
AD0CR_bit.PDN = 1;
loop:
AD0CR_bit.SEL = 0x02;
ADC1 = (AD0DR1 >> 6)&0x3FF; //6 to 15 bits are ADC result
PINSEL0=0x00000001;
printf("\n CH0=%lx",ADC1);
printf("#");
AD0CR_bit.SEL = 0x04;
ADC2 = (AD0DR2 >> 6)&0x3FF; //6 to 15 bits are ADC result
PINSEL0=0x00000001;
printf(" CH1=%lx",ADC2);
printf("*");
goto loop;
}
int putchar(int c)
{
U0THR=c;
while((U0LSR&0x20)!=0x20);
return c;
}
void delay()
{
int i;
for(i=0;i<1000;i++);
}
Analog to Digital Converters are primarily used in industrial process measurements,
RADAR systems and Automation systems.
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 132
The Digital to analog converters are used as digital potentiometers. So it is used in
Direct Digital Synthesizer (DDS) and most of the industrial applications. In electronics, a digital-
to-analog converter (DAC or D-to-A) is a device for converting a digital (usually binary) code to
an analog signal (current, voltage or electric charge).
Example
Input: A binary word 10010111
2
(=151
10
)
Output: Analog signal representing the weighted sum of the non- zero bits in the word.
Example: 2.96 Volts
Normally used DAC types are
/ Binary Weighted Resistor Network
/ R-2R Ladder Network
/ Multiplying DAC
Binary weighted resistor network: The binary weighted resistor network Comprises of a
register and resistor network. The output of each bit of the register will depend on whether a 1
or a 0 is stored in that position
e.g. for a 0 then 0V output
for a 1 then 5V output
Resistance R is inversely proportional to binary weight of each digit
Fig.18.1: Binary Weighted Resistor Network
This is very difficult to manufacture.
R-2R Ladder Resistor Network: The R-2R Ladder Resistor Network has a resistor network
which requires resistance values that differ 2:1 for any sized code word. The principle of the
network is based on Kirchhoffs current rule.
MSB
LSB
4
-
b
i
t
r
e
g
i
s
t
e
r
-
+
R
2R
4R
8R
I
1
I
2
I
3
I
4
R
f
I
f
I S
V
o
V
o
=
I
f
R
f
=
( I
1
+
I
2
+
I
3
+
I
4
)
R
f
DIGITAL TO ANALOG CONVERTER (DAC)
18
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 133
Fig.18.2: R-2R Ladder Network
SFR Associated with DAC
DAC Register (DACR - address 0xE006 C000) - This read/write register includes the digital
value to be converted to analog, and a bit that trades off performance vs. power. Bits 5:0 are
reserved for future, higher-resolution D/A converters.
VALUE: After the selected settling time after this field is written with a new VALUE, the voltage
on the AOUT pin (with respect to VSSA) is VALUE/1024 * V
REF
.
BIAS:
0 The settling time of the DAC is 1 s max, and the maximum current is 700 A.
1 The settling time of the DAC is 2.5 s and the maximum current is 350 A.
Program - Generate a sine wave using DAC
#include<iolpc2148.h>
int main (void)
{
DWORD i = 0;
2R
I/4
2R 2R
I
M
S
B
L
S
B
4-bit register
I/8 I/16
I/2
2R
V
s
-
+
R
f
V
o
2R
R R R
V
o
=
-R
f
( b
3
I 2
+
b
2
I 4
+
b
1
I 8
+
b
0
I 16 )
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 134
/* Initialize DAC */
PINSEL1=0x00040000;
while ( 1 )
{
DACR = (i << 6) | DAC_BIAS;
i++;
if ( i == 1024 )
{
i = 0;
}
}
return 0;
}
DAC Applications
+ Industrial Control Systems
e.g. motor speed & valves
+ Digital Audio
e.g. CD player
+ Digital Communications
e.g. digital telephone systems
+ Waveform Function Generators
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 135
Interfacing computer systems to the outside world is an important issue in a large
number of computer-related disciplines, from human computer interaction, to robotics, to
interactive multimedia, to computer music. In order to do this, the computer systems require
some form of sensors. A sensor is a device that measures a physical quantity and converts it
into a signal, which can be read by an observer or by an instrument. Capturing the data from
sensors is applied in industrial processes. Temperature sensor, Pressure sensor, Humidity
sensor, Acceleration sensor, Flow sensor, level sensor, velocity sensor, Solar radiation sensor,
Wind direction sensor, Fire/Smoke Sensor and proximity sensor are the types of Sensors used.
Temperature Sensor (AD590)
In an industry environment some processes work well within a certain temperature
ranges. If it beyond or reduces the limit it will affect the process output. So, it is necessary to
monitor the temperature by using temperature sensor. There are many types of temperature
sensors that will use various technologies and have different shapes. These sensors are used in
many fields in the industry and in household equipment. Appliances (ovens, refrigerators),
cars (engine, car interior), processing industries (plastic, food, chemical, car, electronics
industries.), domestic and industrial heating facilities uses temperature sensors. Thermocouple
and thermistors are the two types of temperature transducers.
A thermocouple is a junction formed from two dissimilar metals. Actually, it is a pair of
junctions. One at a reference temperature (like 0 C) and the other junction at the temperature
to be measured. A temperature difference will cause a voltage to be developed that is
temperature dependent. (That voltage is caused by something called the Seebeck effect.)
Thermocouples are widely used for temperature measurement because they are inexpensive,
rugged and reliable, and they can be used over a wide temperature range. In particular, other
temperature sensors are useful around room temperature, but the thermocouple can.
Thermistors are inexpensive, easily-obtainable temperature sensors. They are easy to use and
adaptable. Circuits with thermistors can have reasonable output voltages - not the millivolt
outputs thermocouples have. Because of these qualities, thermistors are widely used for simple
temperature measurements. They're not used for high temperatures, but in the temperature
ranges where they work they are widely used.
The AD590 is an integrated-circuit temperature transducer, which produces an output
current proportional to absolute temperature. The device acts as a high impedance constant
current regulator, passing 1mA/K for supply voltages between +4V and +30V. Laser trimming
of the chip's thin film resistors is used to calibrate the device to 298.2mA output at 298.2K
(25C). The AD590 should be used in any temperature-sensing application between -55C to
150C in which conventional electrical temperature sensors are currently employed. The
inherent low cost of a monolithic integrated circuit combined with the elimination of support
circuitry makes the AD590 an attractive alternative for many temperature measurement
situations. The features are
- Linear Current Output : 1mA/K
- Wide Temperature Range : -55C to 150C
- Two-Terminal Device Voltage In/Current Out
SENSOR INTERFACING
19
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 136
- Wide Power Supply Range : +4V to +30V
- Sensor Isolation From Case
- Low Cost
Fig.19.1: AD590, Pin diagram, Interfacing diagram
Smoke Sensor
The fire detection is one of the major precaution system in industry, because significant
loss to business occurs through fires in the workplace. Whether large or small, fire causes
personal suffering, damage to plant, equipment and buildings, and loss of business. The
automatic fire detection system provides the following features:
+ Fire avoidance - in personnel, downtime and repair costs
+ Automated process - Saves costs and man-hours
+ Improved industry safety
+ Higher confidence in safety of material
Smoke detectors are one of those amazing inventions that, because of mass production,
cost practically nothing. And while they cost very little, smoke detectors save thousands of lives
each year. In fact, it is recommended that every home have one smoke detector per floor.
The two most common types of smoke detectors used today: photoelectric detectors and
ionization detectors. The photoelectric detectors are work as photoelectric diodes. Which
senses the lack of light and triggers. The problems of photoelectric detectors are
o It's a pretty big smoke detector.
o It is not very sensitive.
Ionization smoke detectors use an ionization chamber and a source of ionizing
radiation to detect smoke. This type of smoke detector is more common because it is
inexpensive and better at detecting the smaller amounts of smoke produced by flaming fires.
Inside an ionization detector is a small amount (perhaps 1/5000th of a gram) of americium-241.
The radioactive element americium has a half-life of 432 years, and is a good source of alpha
particles. An ionization chamber is very simple. It consists of two plates with a voltage across
them, along with a radioactive source of ionizing radiation. The alpha particles generated by the
americium have the following property: They ionize the oxygen and nitrogen atoms of the air in
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 137
the chamber. To "ionize" means to "knock an electron off of." When you knock an electron off of
an atom, you end up with a free electron (with a negative charge) and an atom missing one
electron (with a positive charge). The negative electron is attracted to the plate with a positive
voltage, and the positive atom is attracted to the plate with a negative voltage (opposites attract,
just like with magnets). The electronics in the smoke detector sense the small amount of
electrical current that these electrons and ions moving toward the plates represent. When
smoke enters the ionization chamber, it disrupts this current -- the smoke particles attach to the
ions and neutralize them. The smoke detector senses the drop in current between the plates
and sets off the horn.
Fig. 19.2: MQ2 Smoke sensor and Interfacing circuit
Proximity Sensor
Proximity sensors are sensors able to detect the presence of
nearby objects without any physical contact. A proximity sensor
often emits an electromagnetic or electrostatic field, or a beam of
electromagnetic radiation (infrared, for instance), and looks for
changes in the field or return signal. The object being sensed is
often referred to as the proximity sensor's target. Different proximity
sensor targets demand different sensors. For example, a capacitive
or photoelectric sensor might be suitable for a plastic target; an
inductive proximity sensor requires a metal target.
3
2
1
4
1
1
-
+
U1A
TL034
R1
100k
R2
1k
5
6
7
4
1
1
-
+
U2B
TL034
To Microcontroller
R3
1k
R4
1k
R5
470 ohm
R6
1k
100k
POT
100k
POT
D1
3.3k
+12v
+12V
-12v
+12v
-12V
+12v
R7
POT
VCC
VCC
SMOKE SENSOR
Embedded System ARM Architecture & RTOS Programming
Vi Microsystems Pvt. Ltd., Chennai 96. 138
The goal of this chapter is to be able to write a short program, which accepts the inputs
(frequency, power level etc) from the user, processes them, communicate with the
measurement equipments, retrieve the measured raw data from these equipments, analyze
data and presents the user in meaningful forms. The concept of VEE programming resembles
that of program flow chart. A box represents each instruction or I/O operation. Boxes are in
turns connected with data flow paths (wires).
Agilent VEE Pro interacts with the world. It interfaces with popular office tools: use
Microsoft
Word for reports, Excel for spreadsheets, Outlook for paging and e-mail, and Access
for database operations. Agilent VEE Pro integrates the .NET Framework and ActiveX,
simplifying common tasks and making powerful system capabilities available to your programs.
Now it is easy to complete tasks such as programmatically managing files, sending an email
report, or invoking a web page.
Agilent VEE Pro supports industry-standard instrument drivers including IVI-COM and
VXI plug & play as well as a variety of legacy drivers. If an industry-standard driver is not
available, use the .dll library supplied with many instruments and PC Cards. In addition to GPIB
connectivity, Agilent VEE Pro allows you to connect directly to LAN and USB enabled
instruments using industry-standard protocols. VXI, PC plug-ins and other back-planes can be
controlled from Agilent VEE Pro.
MATLAB