Monday, 23 July 2018

External Interrupt Using ARM Microcontroller (LPC2148)

Aim:

Although micro controllers can accept inputs from Digital I/O Ports,interrupts are preferred for accepting inputs generated by external events. This is mainly because of the less attention required for an interrupt based program. An Interrupt Event directs the flow of program execution to a totally independent piece of code, known as “Interrupt Sub-Routine”. There are many sources of Interrupts that are available for a micro controller. Most of them are generated by the internal modules and are known as internal interrupts. And there are two pins that accept external signals directly and allows external sources to generate interrupts.

Description:


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.

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.

Interfacing External Interrupts with LPC2148

When an external interrupt signal is occured in LPC2148 Development Board, the message "LOW" will be displayed on PC. 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 Development 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
Tactile Switch




DS1307
SW2 – (INT1)
P0.14
           
SW3 – (INT2)
P0.15

Block Diagram

3 switch

Schematic


Code


// ******************************************************
// Project: Interfacing external interrupt to atmega8
// Author: Hack Projects India
// Module description: Operate single LED
// ******************************************************
#include <lpc214x.h>

void DelayMs(unsigned int count)
{
 unsigned int i,j; 
 for(i=0;i<count;i++)
 {
  for(j=0;j<1000;j++);
 }
}
void ExtInt_Serve1(void)__irq
{
 IO1SET = 0xffffffff;
 DelayMs(1000);
 IO1CLR = 0xffffffff;
 EXTINT |=2;
 VICVectAddr=1;
}

void ExtInt_Init1()
{
 EXTMODE |= 2;      // Edge sensitive mode on EINT1
 EXTPOLAR = 0;      // Falling edge sensitive
 PINSEL0 |= 0x20000000;  // Enable EINT1 on P014
 VICVectCntl0 = 0x20 | 15;  // 15 is index of  EINT1  
 VICVectAddr0 = (unsigned long) ExtInt_Serve1;
 VICIntEnable |= (1<<15); // Enable INT1
}


int main(void)
{
 IO1DIR = 0xffffffff;
 ExtInt_Init1(); //Initialize Interrupt
 while(1)
 {
 }
}

Downloads:

The code was compiled in Keil uvision4 and simulation was made in Proteus v7.7.
To download code and proteus simulation click here.

Further Reading suggestions:

No comments:

Post a Comment