ARM HOW-TO GUIDE Interfacing Interrupts with LPC2148 · PDF file06/12/2014 · C...
-
Upload
trankhuong -
Category
Documents
-
view
290 -
download
3
Transcript of ARM HOW-TO GUIDE Interfacing Interrupts with LPC2148 · PDF file06/12/2014 · C...
ARM HOW-TO GUIDE
Interfacing Interrupts
with LPC2148 ARM
Join the Technical Community Today!
http://www.pantechsolutions.net
Contents at a Glance
ARM7 LPC2148 Slicker Board ........................................... 3
External Interrupts .......................................................... 3
Interfacing External Interrupts ......................................... 4
Interfacing External Interrupts with LPC2148 ................... 5
Pin Assignment with LPC2148 .......................................... 5
Circuit Diagram to Interface Ext-Interrupt with LPC2148 ... 6
Source Code .................................................................... 6
C Program to interface Ext-Interrupt using LPC2148 ......... 7
Testing the External Interrupts with LPC2148 ................. 10
General Information ...................................................... 11
Join the Technical Community Today!
http://www.pantechsolutions.net
ARM7 LPC2148 Slicker Board
The ARM7 LPC2148 Slicker 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 Slicker Kit is proposed to
smooth the progress of developing and debugging of
various designs encompassing of High speed 32-bit
Microcontrollers.
External Interrupts
An interrupt caused by an external source such as the
computer operator, external sensor or monitoring device,
or another computer. Interrupts are special events that
require immediate attention.
Join the Technical Community Today!
http://www.pantechsolutions.net
Interfacing External Interrupts
Fig. 1 shows how to interface the External Interrupt to
microcontroller. Interrupts cause the processor to cease the
running task to serve a special task for which the interrupt
event had occurred. After the special task is over, the
processor resumes performing the original task.
The processor can also serve these events by polling
method. But polling is an inefficient technique as compared
to interrupts. In the polling method, the processor has to
continuously wait for the event signal. Thus it always
remains busy using extra resources.
Join the Technical Community Today!
http://www.pantechsolutions.net
Fig. 1 Interfacing External Interrupts to Microcontroller
Interfacing External Interrupts with LPC2148
We now want to display some messages in PC when
occur an external interrupt signal in LPC2148 Slicker Board.
The Interrupt signal is occurred by using switches. When the
switch is pressed to LOW, then the external interrupt is
occurred.
The Vectored Interrupt Controller (VIC) takes 32
interrupt request inputs and programmable assigns them
into 3 categories, FIQ, vectored IRQ, and non-vectored IRQ.
The ARM7 LPC2148 Slicker board has two numbers of
External Interrupts, connected with I/O Port lines (P0.14 &
P0.15) as switches.
Pin Assignment with LPC2148
Interrupts LPC2148 Lines Interrupts
Join the Technical Community Today!
http://www.pantechsolutions.net
Circuit Diagram to Interface Ext-Interrupt with LPC2148
Source Code
Tact
ile
Swit
ch
DS1
30
7 SW5 – (INT1) P0.14
SW6– (INT2) P0.15
ARM7
INTR
3.3V
C68
22pf
C69
22pf
X29
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
P0.1545
P0.1441
C9
100n
C10
100n
R622K
SW6
INT2
R522K
SW5
INT1
3V3
INTERRUPTS
3V3
Join the Technical Community Today!
http://www.pantechsolutions.net
The Interfacing External Interrupt with LPC2148
program is very simple and straight forward, that accessed
by using switches. When the external interrupts occurring,
some messages are displayed in PC through serial port at
9600 baud rate. The C programs are written in Keil
software.
C Program to interface Ext-Interrupt using LPC2148 ***************************************************************************************
Title : Program to interface an external Interrupt ***************************************************************************************
#include<LPC214x.h> // Define LPC2148 Header File
#include <stdio.h>
int volatile EINT1 = 0;
int volatile EINT2 = 0;
void ExtInt_Serve1(void)__irq;
void ExtInt_Serve2(void)__irq;
void ExtInt_Serve1(void)__irq
{
++EINT1;
EXTINT |= 2;
VICVectAddr = 1;
}
void ExtInt_Serve2(void)__irq
{
++EINT2;
Join the Technical Community Today!
http://www.pantechsolutions.net
EXTINT |= 4;
VICVectAddr = 0;
}
void main(void)
{
Serial_Init();
ExtInt_Init1(); //Initialize Interrupt 1
ExtInt_Init2(); //Initialize Interrupt 2
putchar(0x0C);
printf ("***************** External Interrupt
Demo ***************************\n\n\r");
DelayMs(100);
printf (">>> Press Interrupt Keys SW2(INT1) and
SW3(INT2) for Output... \n\n\n\r");
DelayMs(100);
while(1)
{
DelayMs(500);
printf("INT1 Generated : %d | INT2 Generated
: %d \r", EINT1, EINT2);
DelayMs(500);
}
}
void ExtInt_Init2(void)
{
EXTMODE |= 4; //Edge sensitive mode on EINT2
EXTPOLAR = 0; //Falling Edge Sensitive
PINSEL0 |= 0x80000000; //Enable EINT2 on P0.15
VICVectCntl1 = 0x20 | 16; // 16 is index of EINT2
Join the Technical Community Today!
http://www.pantechsolutions.net
VICVectAddr1 = (unsigned long) ExtInt_Serve2;
VICIntEnable |= 1<<16; //Enable EINT2
}
void ExtInt_Init1(void)
{
EXTMODE |= 2; //Edge sensitive mode on EINT1
EXTPOLAR = 0; //Falling Edge Sensitive
PINSEL0 |= 0x20000000; //Enable EINT2 on P0.14
VICVectCntl0 = 0x20 | 15; //15 is index of EINT1
VICVectAddr0 = (unsigned long) ExtInt_Serve1;
VICIntEnable |= 1<<15; //Enable EINT1
}
void Serial_Init(void)
{
PINSEL0 |= 0X00000005; //Enable Txd0 and Rxd0
U0LCR = 0x00000083; //8-bit data,1-stop bit
U0DLL = 0x00000061; //XTAL = 12MHz
U0LCR = 0x00000003; //DLAB = 0;
}
void DelayMs(unsigned int count)
{
unsigned int i,j;
for(i=0;i<count;i++)
{
for(j=0;j<1000;j++);
}
}
To compile the above C code you need the KEIL
software. They must be properly set up and a project with
Join the Technical Community Today!
http://www.pantechsolutions.net
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 Slicker Board.
The Flash Magic software is used to download the hex
file into your microcontroller IC LPC2148 through UART0.
Testing the External Interrupts with LPC2148
Give +3.3V power supply to LPC2148 Slicker Board; the
serial cable is connected between the LPC2148 Slicker
Board and PC. Open the Hyper Terminal screen, select
which port you are using and set the default settings. Now
the screen should show which external interrupt is selected.
When you pressed the external interrupt key, the
screen should update which interrupt is now pressed. The
Join the Technical Community Today!
http://www.pantechsolutions.net
external Interrupts are controlled by using switches. If any
data is not coming in Hyper Terminal, then you just check
the serial cable is working or not. 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.
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,
Interfacing UART with LPC2148 Microcontroller.
Join the Technical Community Today!
http://www.pantechsolutions.net
Interfacing Keys with LPC2148 Microcontroller.
User Manual of LPC2148 Slicker Board.
Tutorial of how to create & Debug a project in KEIL.
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?
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.