12
ARM HOW-TO GUIDE Interfacing Switch with LPC2148 ARM

ARM HOW-TO GUIDE Interfacing Switch with LPC2148 … · 27.12.2014 · Pin Assignment with LPC2148 ... way that all the possible features of the microcontroller will ... The Interfacing

Embed Size (px)

Citation preview

Page 1: ARM HOW-TO GUIDE Interfacing Switch with LPC2148 … · 27.12.2014 · Pin Assignment with LPC2148 ... way that all the possible features of the microcontroller will ... The Interfacing

ARM HOW-TO GUIDE

Interfacing Switch with

LPC2148 ARM

Page 2: ARM HOW-TO GUIDE Interfacing Switch with LPC2148 … · 27.12.2014 · Pin Assignment with LPC2148 ... way that all the possible features of the microcontroller will ... The Interfacing

Join the Technical Community Today!

http://www.pantechsolutions.net

Contents at a Glance

ARM7 LPC2148 Primer Board ........................................... 3

Switch ............................................................................. 3

Interfacing Switch ............................................................ 4

Interfacing Switch with LPC2148 ...................................... 5

Pin Assignment with LPC2148 .......................................... 5

Circuit Diagram to Interface Switch with LPC2148 ............ 6

Source Code .................................................................... 6

C Program to switch functions using LPC2148 ................... 7

Testing the switch with LPC2148 ...................................... 9

General Information ........................................................ 9

Page 3: ARM HOW-TO GUIDE Interfacing Switch with LPC2148 … · 27.12.2014 · Pin Assignment with LPC2148 ... way that all the possible features of the microcontroller will ... The Interfacing

Join the Technical Community Today!

http://www.pantechsolutions.net

ARM7 LPC2148 Primer Board

The ARM7 LPC2148 Primer board is specifically

designed to help students to master the required skills in

the area of embedded systems. The kit is designed in such

way that all the possible features of the microcontroller will

be easily used by the students. The kit supports in system

programming (ISP) which is done through serial port.

NXP’s ARM7 (LPC2148), ARM Primer Kit is proposed to

smooth the progress of developing and debugging of

various designs encompassing of High speed 32-bit

Microcontrollers.

Switch

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.

Page 4: ARM HOW-TO GUIDE Interfacing Switch with LPC2148 … · 27.12.2014 · Pin Assignment with LPC2148 ... way that all the possible features of the microcontroller will ... The Interfacing

Join the Technical Community Today!

http://www.pantechsolutions.net

Interfacing Switch

Fig. 1 shows how to interface the switch to

microcontroller. A simple switch has an open state and

closed state. However, a microcontroller needs to see a

definite high or low voltage level at a digital input. 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.

Fig. 1 Interfacing switch to Microcontroller

Page 5: ARM HOW-TO GUIDE Interfacing Switch with LPC2148 … · 27.12.2014 · Pin Assignment with LPC2148 ... way that all the possible features of the microcontroller will ... The Interfacing

Join the Technical Community Today!

http://www.pantechsolutions.net

Interfacing Switch with LPC2148

We now want to control the LED by using switches in

LPC2148 Primer Board. It works by turning ON a LED & then

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

The ARM7 LPC2148 Primer board 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.

Pin Assignment with LPC2148

Slide Switch LPC2148 Lines Input Logic Selection

DIG

ITA

L IN

PU

TS

SW20 P1.24

Make Switch Close – Low

Make Switch Open – High

SW21 P1.25

SW22 P1.26

SW23 P1.27

SW24 P1.28

SW25 P1.29

SW26 P1.30

SW27 P1.31

Page 6: ARM HOW-TO GUIDE Interfacing Switch with LPC2148 … · 27.12.2014 · Pin Assignment with LPC2148 ... way that all the possible features of the microcontroller will ... The Interfacing

Join the Technical Community Today!

http://www.pantechsolutions.net

Circuit Diagram to Interface Switch with LPC2148

Source Code

The Interfacing switch with LPC2148 program is very

simple and straight forward, that controls led by using

switches when it going LOW or HIGH.

3.3V

C56

22pf

C57

22pf

X23

12MHz

LPC2148

U16

VSS16 V

DD

A7

VSS218

VD

D3

23

VSS325

VD

D2

43

VSS442

VR

EF

63

XT

AL1

62

XT

AL2

61

VSSA59

VD

D1

51

VSS550

P1.2432

P1.2528

P1.2624

P1.2764

P1.2860

P1.2956

P1.3052

P1.3120

R24

1K-SIL

123456789

R27 10k

R28 10k

R29 10k

R32 10k

R38 10k

R39 10k

R42 10k

R43 10k

SW20

SW KEY-SPST

12

3SW21

SW KEY-SPST

12

3SW22

SW KEY-SPST

12

3SW23

SW KEY-SPST

12

3SW24

SW KEY-SPST

12

3SW25

SW KEY-SPST

12

3SW26

SW KEY-SPST

12

3SW27

SW KEY-SPST

12

3

3V3

SLIDE SWITCH

Page 7: ARM HOW-TO GUIDE Interfacing Switch with LPC2148 … · 27.12.2014 · Pin Assignment with LPC2148 ... way that all the possible features of the microcontroller will ... The Interfacing

Join the Technical Community Today!

http://www.pantechsolutions.net

C Program to switch functions using LPC2148 ***************************************************************************************

Title : Program to Blink LEDs controlling by switches ***************************************************************************************

#include<LPC214x.h> // Define LPC2148 Header File

#include <stdio.h>

#define LED 16

#define Switch 24

void Delay(int);

int main(void)

{

unsigned char Status=1;

PINSEL2 &= 0xFFFFFFF3; //Configure P1.16 - P1.31 as GPIO

IO1DIR = 0x00 << Switch;//Configure P1.24 - P1.31 as Input

IO1DIR|= 0xFF << LED; //Configure P1.16 - P1.23 as Output

while(1)

{

Status = 1;

IOSET1 = 0xFF << LED;

Delay (10);

IOCLR1 = 0xFF << LED;

Delay (10);Delay (10);Delay (10);

while (~Status)

{

Status = ((IO1PIN & (0xFF << Switch)) >> Switch);

IO1PIN = ((~Status) << LED);

}

}

}

Page 8: ARM HOW-TO GUIDE Interfacing Switch with LPC2148 … · 27.12.2014 · Pin Assignment with LPC2148 ... way that all the possible features of the microcontroller will ... The Interfacing

Join the Technical Community Today!

http://www.pantechsolutions.net

void Delay(int n)

{

int p,q;

for(p=0;p<n;p++)

{

for(q=0;q<0x9990;q++);

}

}

To compile the above C code you need the KEIL

software. They must be properly set up and a project with

correct settings must be created in order to compile the

code. To compile the above code, the C file must be added

to the project.

In Keil, you want to develop or debug the project

without any hardware setup. You must compile the code for

generating HEX file. In debugging Mode, you want to check

the port output without LPC2148 Primer Board.

The Flash Magic software is used to download the hex

file into your microcontroller IC LPC2148 through UART0.

Page 9: ARM HOW-TO GUIDE Interfacing Switch with LPC2148 … · 27.12.2014 · Pin Assignment with LPC2148 ... way that all the possible features of the microcontroller will ... The Interfacing

Join the Technical Community Today!

http://www.pantechsolutions.net

Testing the switch with LPC2148

Give +3.3V power supply to LPC2148 Primer Board; the

switches are connected with the LPC2148 Primer Board.

Check the LED’s & switches are working or not. If you not

reading any output signal in LED, then you just check the

jumper connections. Otherwise you just check the code

with debugging mode in Keil.

If you want to see more details about debugging just

see the videos in below link.

How to Create & Debug a Project in Keil.

General Information

For proper working use the components of exact values

as shown in Circuit file. Wherever possible use new

components.

Page 10: ARM HOW-TO GUIDE Interfacing Switch with LPC2148 … · 27.12.2014 · Pin Assignment with LPC2148 ... way that all the possible features of the microcontroller will ... The Interfacing

Join the Technical Community Today!

http://www.pantechsolutions.net

Solder everything in a clean way. A major problem

arises due to improper soldering, solder jumps and

loose joints.

Use the exact value crystal shown in schematic.

More instructions are available in following articles,

User Manual of LPC2148 Primer Board.

Tutorial of how to create & Debug a project in Keil.

Interfacing LED with LPC2148.

Page 11: ARM HOW-TO GUIDE Interfacing Switch with LPC2148 … · 27.12.2014 · Pin Assignment with LPC2148 ... way that all the possible features of the microcontroller will ... The Interfacing

Join the Technical Community Today!

http://www.pantechsolutions.net

Pantech solutions creates information packed technical

documents like this one every month. And our website is a rich

and trusted resource used by a vibrant online community of

more than 1,00,000 members from organization of all shapes

and sizes.

Did you enjoy the read?

Page 12: ARM HOW-TO GUIDE Interfacing Switch with LPC2148 … · 27.12.2014 · Pin Assignment with LPC2148 ... way that all the possible features of the microcontroller will ... The Interfacing

Join the Technical Community Today!

http://www.pantechsolutions.net

What do we sell?

Our products range from Various Microcontroller

development boards, DSP Boards, FPGA/CPLD boards,

Communication Kits, Power electronics, Basic electronics,

Robotics, Sensors, Electronic components and much more . Our

goal is to make finding the parts and information you need

easier and affordable so you can create awesome projects and

training from Basic to Cutting edge technology.