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

Introduction to Advanced Controllers

The document provides an introduction to advanced controllers, specifically comparing the 8051 and ARM architectures, detailing ARM's history, pipelining examples, and features of the LPC2148 microcontroller. It outlines the functionalities of various registers, GPIO configurations, and interfacing with components like LEDs, switches, and LCDs. Additionally, it includes coding examples for controlling LEDs and interfacing with switches and LCDs using the LPC2148 microcontroller.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Introduction to Advanced Controllers

The document provides an introduction to advanced controllers, specifically comparing the 8051 and ARM architectures, detailing ARM's history, pipelining examples, and features of the LPC2148 microcontroller. It outlines the functionalities of various registers, GPIO configurations, and interfacing with components like LEDs, switches, and LCDs. Additionally, it includes coding examples for controlling LEDs and interfacing with switches and LCDs using the LPC2148 microcontroller.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 56

Introduction to Advanced

Controllers
Difference between 8051 and ARM
ARM- History
ARM Pipelining examples
ARM7TDMI Pipeline

FETCH DECODE EXECUTE


Reg. Reg.
Read Shift ALU Write

1 Clock cycle

ARM9TDMI Pipeline

FETCH DECODE EXECUTE MEMORY WRITE


Reg. Reg.
Shift ALU access
Read Write

1 Clock cycle

• Fetch: Read Op-code from memory to internal Instruction Register


• Decode: Activate the appropriate control lines depending on Opcode
• Execute: Do the actual processing
ARM7TDMI Pipelining (I)

1 FETCH DECODE EXECUTE

2 FETCH DECODE EXECUTE

3 FETCH DECODE EXECUTE


instruction
time

• Simple instructions (like ADD) Complete at a rate of one per cycle


ARM7TDMI Pipelining (II)
More complex instructions:

1 ADD FETCH DECODE EXECUTE

2 STR FETCH DECODE Cal. ADDR Data Xfer.

3 ADD FETCH stall DECODE EXECUTE

4 ADD FETCH stall DECODE EXECUTE

5 ADD FETCH DECODE EXECUTE


instruction
time

STR : 2 effective clock cycles (+1 cycle)


Why Cortex
Blinking LED Using ARM7 LPC2148
Microcontroller
• ARM is generally known as Advanced RISC Machine is a reduced instruction set
computer (RISC) instruction set architecture (ISA) developed by British company ARM
Holdings. The ARM architecture is the most widely used 32-bit instruction set architecture.
ARM 7 TDMI

• LPC2000 is a series of 32-bit microcontrollers from NXP Semiconductors. They are based on
a 1.8 V ARM7TDMI-S core operating at up to 80 MHz together with a variety of peripherals
including serial interfaces, 10-bit ADC/DAC, timers, capture compare, PWM, USB interface,
and external bus options. Flash memory ranges from 32 kB to 512 kB RAM ranges from 4 kB
to 96 kB.

• The LPC214X is a series like LPC2141, LPC2142, LPC2144, LPC2146, and LPC2148 are
full-speed USB 2.0 devices in LQFP64 packages. Multiple peripherals are supported including
one or two 10-bit ADCs and an optional 10-bit DAC.

• The LPC213X series are LPC2364/66/68 and the LPC2378 are full-speed USB 2.0 devices
with 2 CAN interface and 10/100 Ethernet MAC in LQFP100 andLQFP144 packages.
Multiple peripherals are supported including a 10-bit 8-channel ADC and a 10-bit DAC.
LPC 2148
• LPC2148 is the widely used IC from ARM-7 family. It is manufactured by Philips and it is
pre-loaded with many inbuilt peripherals making it more efficient and a reliable option for the
beginners as well as high end application developer.

Features
PINSEL Register

• A 32-bit register is used to select the function of the pins in which the user needs it to operate.
As I said there are four functions for each pin of the controller, which the first function was
GPIO ( General Purpose Input Output ). It means that the pin can either act as an Input or
Output with no specific functions.

• There is totally three PINSEL register in LPC2148 Controller in order to control the functions
of the Pins in the respective ports.

• PINSEL0 – Controls functions of Port0.0 – Port0.15


• PINSEL1 – Controls functions of Port0.16-Port0.31
• PINSEL2 – Controls functions of Port1.16-Port1.31
I/O PORT

• LPC2141/2/4/6/8 has two 32-bit General Purpose I/O ports. A total of 30 input/output and
a single output only pinout of 32 pins are available on PORT0. PORT1 has up to 16 pins
available for GPIO functions. PORT0 and PORT1 are controlled via two groups of 4 registers.
REGISTER DESCRIPTION

IOPIN
• The register will give the logic value of the pin regardless of whether the pin is configured for
input or output, or as GPIO or an alternate digital function.

• As an example, a particular port pin may have GPIO input, GPIO output, UART receive, and
PWM output as selectable functions. Any configuration of that pin will allow its current logic
state to be read from the IOPIN register.

• If a pin has an analog function as one of its options, the pin state cannot be read if the analog
configuration is selected. Selecting the pin as an A/D input disconnects the digital features of
the pin.

• In that case, the pin value read in the IOPIN register is not valid. Writing to the IOPIN register
stores the value in the port output register, bypassing the need to use both the IOSET and
IOCLR registers to obtain the entire written value.
IOSET
• This register is used to produce a HIGH level output at the port pins configured as GPIO in an
OUTPUT mode.
• Writing 1 produces a HIGH level at the corresponding port pins. Writing 0 has no effect. If
any pin is configured as an input or a secondary function, writing 1 to the corresponding bit in
the IOSET has no effect.

IODIR
• This word accessible register is used to control the direction of the pins when they are
configured as GPIO port pins. Direction bit for any pin must be set according to the
pin functionality.

IOCLR
• This register is used to produce a LOW-level output at port pins configured as GPIO in an
OUTPUT mode. Writing 1 produces a LOW level at the corresponding port pin and clears the
corresponding bit in the IOSET register. Writing 0 has no effect.
• If any pin is configured as an input or a secondary function, writing to IOCLR has no effect.
ARM7 Board-Features

• On-board NXP’s LPC2148 microcontroller with serial bootloader


• USB powered or externally powered

• On board USB to Serial converter to implement UART communication using


the standard USB port on the computer

• The USB to Serial Converter can also be used as a programmer to program the
device

• Breakout to all the port pins for interfacing external circuits and ADD-ONsOn-
board crystal of 12MHz to clock the microcontroller

• On-board crystal of 32.768kHz to clock the on-chip RTCProtection diodes for


external power to the microcontroller and RTC battery backupPush button to
hardware reset the MCUOne on-board LED to display status of a GPIO
pinBreadboard compatible development boardWell-documented top and bottom
side for easy hardware troubleshooting.
POWER SUPPLY
• LPC-P2148 can take power from three sources:
• – External power supply 5.0V DC
• – +5V_USB from USB connector
• – Extension pins VIN and GND

RESET
• LPC2148 pin 57 (RST) and RESET button

CLOCK
• Quartz crystal with name Q1 (12 MHz) is connected to
LPC2148 pin 61 (X2) and pin 62 (X1).
• Quartz crystal with name Q2 (32.768 kHz) is connected to
LPC2148 pin 3 (RTCX1) and pin 5 (RTCX2).
LED
• LED does not emit white light, but LEDs emit nearly monochromatic light,
making them highly efficient for colored light applications such as traffic
lights and exit signs. However, to be used as a general light source, white
light is needed.

White light can be achieved with LEDs in three ways:

• Phosphor conversion, in which a phosphor is used on or near the LED to


convert the colored light to white light.
• RGB systems, in which light from multiple monochromatic LEDs (e.g.,
red, green, and blue) is mixed, resulting in white light.
• A hybrid method, which uses both phosphor-converted (PC) and
monochromatic LEDs.The potential of LED technology to produce high-
quality white light with unprecedented energy efficiency is the primary
motivation for the intense level of research and developmentcurrently
supported by the U.S. Department of Energy.
LPC2148 With LED Connection Diagram
• If you have ready made boards, then just connect P1.16(pin) with 1k
resistance-----> +5v.
• When P1.16 status is High(+5v), then LED will not glow and when P1.16
is at Low(0v) status then LED will glow.
• [P1.16/TRACEPKT0] — General purpose input/output digital pin
(GPIO). Standard I/O port with internal pull-up.
• ---- TRACEPKT0 — Trace Packet, bit 0.

IOPIN: The current state of the GPIO configured port pins can always be read
from this register, regardless of pin direction.THEY are----
• IO0PIN(PORT0) &
• IO1PIN(PORT1)

IODIR: GPIO Port Direction control register. This register individually


controls the direction of each port pin.
• IO0DIR(PORT0) &
• IO1DIR(PORT1)
CODING

#include<lpc214x.h>
void delay();
void main()
{
IO0DIR |=0XfffffFFF; //Port 0 is now acting as a output pin
while(1) {
IOSET0 |=0XfffffFFF; //Port 0's all pins are high now (LED is glowing)
delay();
IOCLR0 |=0XFFFfffff; //Port 0's all pins are low now (LED is OFF)
delay();
}
}
void delay()
{
unsigned int i;
for(i=0;i<30000;i++);
}
OUTPUT
Switch Interfacing – LPC2148

• A switch is an electrical component that can break an electrical circuit, interrupting


the current or diverting it from one conductor to another. A switch may be directly
manipulated by a human as a control signal to a system, or to control power flow in
a circuit.

• A simple switch has an open state and closed state.

• A switch requires a pull-up or pull-down resistor to produce a definite high or low


voltage when it is open or closed. A resistor placed between a digital input and the
supply voltage is called a “pull-up” resistor because it normally pulls the pin’s
voltage up to the supply.

• Controlling LED by using switches in LPC2148. It works by turning ON a LED &


then turning it OFF when switch is going to LOW or HIGH.

• The ARM7 LPC2148 has eight numbers of point LEDs, connected with I/O Port
lines (P1.16 – P1.23) to make port pins high. Eight switches, connected with I/O
port lines (P1.24 – P1.31) are used to control eight LEDs.
CODING
#include<lpc214x.h>
void delay();
void main()
{
IO0DIR |=0XfffffFFF; //Port 0 is now acting as a output pin
IO1DIR = 0x0; //Port 1 is now acting as a input pin
while(1)
{
if((IO1PIN & (1<<16)) ==0) //Checking 16th pin of Port 1
IOSET0 |=0XfffffFFF; //Port 0's all pins are high now (LED is glowing)
else
IOCLR0 |=0XFFFfffff; //Port 0's all pins are low now (LED is OFF)
}
}
void delay()
{
unsigned int i;
for(i=0;i<30000;i++);
}
OUTPUT
LCD Interfacing with LPC2148

• LCDs (Liquid Crystal Displays) are used for displaying status or parameters in
embedded systems.
• We always use devices made up of Liquid Crystal Displays (LCDs) like computers,
digital watches, and also DVD and CD players.
• A 16×2 LCD display is a very basic module and is very commonly used in various
devices and circuits. These modules are preferred over seven segments and other
multi-segment LEDs.
• The reasons being: LCDs are economical; easily programmable; have no limitation
of displaying special & even custom characters (unlike in seven segments),
animations, and so on.
• A 16×2 LCD means it can display 16 characters per line and there are 2 such lines.
In this LCD each character is displayed in a 5×7 pixel matrix.
• This LCD has two registers, namely, Command and Data.
• The command register stores the command instructions given to the LCD. A
command is an instruction given to LCD to do a predefined task like initializing it,
clearing its screen, setting the cursor position, controlling the display, etc.
• The data register stores the data to be displayed on the LCD. The data is the ASCII value
of the character to be displayed on the LCD.

Pin Diagram

•LCD 16x2 is 16 pin device which has 8 data pins (D0-D7) and 3 control pins (RS,
RW, EN). The remaining 5 pins are for supply and backlight for the LCD.

•The control pins help us configure the LCD in command mode or data mode. They
also help configure read mode or write mode and also when to read or write.

•LCD 16x2 can be used in 4-bit mode or 8-bit mode depending on the requirement of
the application. In order to use it we need to send certain commands to the LCD in
command mode and once the LCD is configured according to our need, we can send
the required data in data mode.
Interfacing Diagram 4 bit
mode
•Since we are using LCD in 4-bit mode, we require only 4 Data pins.

•LCD Data pins D4-D7 are connected to pins P0.12-P0.15 of Port 0.

•LCD control pins RS, RW and EN are connected to P0.4, P0.5 P0.6 respectively.
Interfacing Diagram 8 bit mode
CODING
#include<lpc214x.h>
#define bit(x) (1<<x)
#define delay for(i=0;i<1000;i++);
unsigned int i;
void lcd_int();
void dat(unsigned char);
void cmd(unsigned char);
void string(unsigned char *);
void main()
{
IO0DIR|=0XFFF;
lcd_int();
cmd(0x8a);
string("EMBETRONICX.COM ");
while(1) {
cmd(0x18);
delay;
}
}
void lcd_int()
{
cmd(0x30);
cmd(0x0c);
cmd(0x06);
cmd(0x01);
cmd(0x80);
}
void cmd(unsigned char a)
{
IO0PIN&=0x00;
IO0PIN|=(a<<0);
IO0CLR|=bit(8); //rs=0
IO0CLR|=bit(9); //rw=0
IO0SET|=bit(10); //en=1
delay;
IO0CLR|=bit(10); //en=0
}
void dat(unsigned char b)
{
IO0PIN&=0x00;
IO0PIN|=(b<<0);
IO0SET|=bit(8); //rs=1
IO0CLR|=bit(9); //rw=0
IO0SET|=bit(10); //en=1
delay;
IO0CLR|=bit(10); //en=0
}
void string(unsigned char *p)
{
while(*p!='\0') {
dat(*p++);
}
}

You might also like