On 20/04/2010 12:29, 42Bastian wrote: > Am 20.04.2010 07:31, schrieb KARTHICK, V.S.
KARTHICK:
>> hi all
>> I AM NEW TO LPC2138 AND I AM TRYING TO USE INTERRUPT IN MY PROJECTS.
>
> WHY ARE YOU SHOUTING AT US ?
>
Reply by "KARTHICK, V.S. KARTHICK"●April 20, 20102010-04-20
hi all
I AM NEW TO LPC2138 AND I AM TRYING TO USE INTERRUPT IN MY PROJECTS.
I VE READ THE USER MANUAL AND DID THE SETTINGS FOR THE EXTERNAL INTERRUPT.
FOR THE TIME BEING I AM JUS TRYING TO CONNECT A SWITCH TO ONE OF THE EXTINT
PINS(P0.14 here) AND SWITCH ON AN LED.. THE CODE IS AS FOLLOWS..
THE PROBLEM WITH IT IS THAT THE ISR IS NOT GETTING EXECUTED EVEN WHEN THE SWITCH
GOES ON OR EVEN OFF.. CAN SUMONE PLEASE SUGGEST ME A SOLUTION TO THIS PROBLEM AT
THE EARLIEST..
I AM USING KEIL COMPILER AND PROTEUS FOR SIMULATION... I DUNNO IF I HAD TO MAKE
ANY CHANGES IN THE STARTUP CODE FOR RISING INTERRUPT...
KINDLY HELP ME OUT...
THANKS IN ADVANCE....
****************************************************************************************************
#include
void EXTINTVectoredIRQ (void)__irq;
int main (void)
{
int i, k;
//Set the LED pins as outputs
IODIR0 = 0x00000C02;
//Turn OFF the LED pins
IOSET0 = 0x00000C00;
//Set P0.14 to EINT1
PINSEL0 = 0x20000000;
/*NOTE:
VICVectCntl0
----------------------------------
Vector control 0 register. Vector Control Registers 0-15 each
control
one of the 16 vectored IRQ slots. Slot 0 has the highest priority
and
slot 15 the lowest.
Refer to page 57, Table 52 of UM10139 PDF for details
*/
//select a priority slot for a given interrupt
VICVectCntl0 = 0x0000002F;
/*Note:
Vector Address registers 0-15 (VICVectAddr0-15 - 0xFFFF F100-13C)
----------------------------------
These are a read/write accessible registers. These registers hold
the
addresses of the Interrupt Service routines (ISRs) for the 16
vectored
IRQ slots.
*/
//pass the address of the IRQ into the VIC slot
VICVectAddr0 = (unsigned)EXTINTVectoredIRQ;
/*Note:
Interrupt Enable register (VICIntEnable - 0xFFFF F010)
----------------------------------
When this register is read, 1s indicate interrupt requests or
software
interrupts that are enabled to contribute to FIQ or IRQ. When this
register is written, ones enable interrupt requests or software
interrupts to contribute to FIQ or IRQ, zeroes have no effect.
*/
//enable interrupt
EXTMODE=2;
EXTPOLAR=2;
VICIntEnable = 0x00008000;
while(1)
{
//Blink LEDs,
//While P0.14 is brought low an interrupt will occur. In the ISR
//the buzzer will BEEP. To Exit ISR, bring P0.14 high again.
for (i = 0; i < 500000; i++ );
//Turn OFF the LED pins
IOSET0 = 0x00000C00;
for (k = 0; k < 500000; k++ );
//Set the LED pins
IOCLR0 |= 0x00000C00;
}
}
void EXTINTVectoredIRQ (void) __irq
{
IODIR0=0X02;// SELECTING THE IO DIRECTION FOR OUTPUT PINS
IOSET0=0X02; // SETTING THE PINS TO TURN ON THE LED...
//Clear the peripheral interrupt flag
EXTINT = 0x00000002;
//Dummy write to signal end of interrupt
VICVectAddr = 0x00000000;
}