HElp And Suggestions Needed Instantly

I wanted to interface the interrupt program which have given below into the keypad scanning program which is also given below :

For each key press i have to generate an interrupt whose function is to display a value in the grpahics lcd.

Interrupt program :

#include <NXP/iolpc2148.h>

#include <intrinsics.h>

#define XTALFREQ 12000000 //XTAL frequency in Hz

#define PCLKFREQ (XTALFREQ/4) //pclk must always be XTALFREQ/4?

int main(void);

__irq __arm void IRQ_ISR_Handler (void);

void Btn2DownISR(void);

void NonVectISR(void);

void feed (void);

int main(void)

{

/* Preliminary setup of the VIC. Assign all interrupt channels to IRQ */

VICIntSelect = 0; // Set all VIC interrupts to IRQ for now

VICIntEnClear = 0x00000000; // Diasable all interrupts

VICSoftIntClear = 0x00000000; // Clear all software interrutps

VICProtection = 0; // VIC registers can be accessed in User or

// privileged mode

VICVectAddr = 0; // Clear interrupt

VICDefVectAddr = 0; // Clear address of the default ISR

/*Configure the pins that the buttons are hooked up to to be external

interrupts */

PINSEL1_bit.P0_30=0x2; // Set Port pin P0.15 function to EINT3

//LED Conmfiguration

PINSEL2 = 0X00000000; // P1.24 TO P1.31 as GPIO

IO1DIR = 0XFF000000; // p1.24 TO P1.31 Configured as Output port.

VICProtection = 0; // Accesss VIC in USR | PROTECT

// VICDefVectAddr = (unsigned int)&NonVectISR; // Install default ISR addr

/* Set up the button 1 pressed interrupt on EINT0 */

VICIntSelect &= ~(1<<VIC_EINT3); // IRQ on external int 0.

VICVectAddr1 = (unsigned int)&Btn2DownISR; // Install ISR in VIC addr slot

VICVectCntl1 = 0x20 | VIC_EINT3; // Enable vec int for EINT 0.

VICIntEnable |= (1<<VIC_EINT3); // Enable EINT0 interrupt.

__enable_interrupt(); // Global interrupt enable

/*This is the foreground loop, which looks at data coming from the background

loop. The user can insert own code to react to timer and button driven

events */

while(1) // Foreground Loop

{

IO1SET=0XFF000000; // P1.24 TO P1.31 goes to high state

}

}

__irq __arm void irq_handler (void)

{

void (*interrupt_function)();

unsigned int vector;

vector = VICVectAddr; // Get interrupt vector.

interrupt_function = (void(*)())vector;

(*interrupt_function)(); // Call vectored interrupt function

VICVectAddr = 0; // Clear interrupt in VIC

}

__fiq __arm void fiq_handler (void)

{

while(1);

}

void Btn2DownISR(void)

{

EXTINT_bit.EINT3 = 1; // Try to reset external interrupt flag.

IO1CLR=0XFF000000; // P1.24 TO P1.31 goes to high state

}

keypadscannin program ::

#include<nxp/iolpc2148.h>

#define DESIRED_BAUDRATE 19200

#define CRYSTAL_FREQUENCY_IN_HZ 12000000

#define PCLK CRYSTAL_FREQUENCY_IN_HZ // since VPBDIV=0x01

#define DIVISOR (PCLK/(16*DESIRED_BAUDRATE))

//static void systemInit(void);

void Arm_Uart0_Init();

void ARM_INIT();

void serial_tx();

char serial_tr(char ch);

void delay_ms();

char arr=“Vi Microsystem Pvt Ltd \n”;

unsigned long int data = {0x0E000000,0x0D000000,0x0B000000,0x07000000};

void delay_ms()

{

int i,j;

for(i=0;i<=0xfff;i++)

for(j=0;j<=0xf0;j++);

}

char serial_tr(char ch)

{

if (ch==‘\n’)

{

while (!(U0LSR&0x20)); //wait until Transmit Holding Register is empty

U0THR=‘\r’; //then store to Transmit Holding Register

}

while (!(U0LSR&0x20)) {} //wait until Transmit Holding Register is empty

U0THR=ch; //then store to Transmit Holding Register

return ch;

}

void Arm_Uart0_Init() //UART Config.

{

U0LCR=0x83; // U0LCR: UART0 Line Control Register.

// 0x83: enable Divisor Latch access, set 8-bit word length.

// 1 stop bit, no parity, disable break transmission.

VPBDIV=0x01; // VPBDIV: VPB bus clock divider 0x01: PCLK = processor clock .

U0DLL=DIVISOR&0xFF; // U0DLL: UART0 Divisor Latch (LSB).

U0DLM=DIVISOR>>8; // U0DLM: UART0 Divisor Latch (MSB).

U0LCR=0x03 ; // U0LCR: UART0 Line Control Register

// 0x03: same as above, but disable Divisor Latch access.

// And same time U0THR (Transmitting register writing)holding the data.

U0FCR=0x05 ; // U0FCR: UART0 FIFO Control Register

// 0x05: Clear Tx FIFO and enable Rx and Tx FIFOs

serial_tx();

}

void serial_tx()

{

int i;

for(i=0;arr*!=‘\0’;i++)*
{
serial_tr(arr);
}
}
void ARM_INIT()
{
PINSEL0 = 0x00000005; //Pin selction for Serial Port.
PINSEL1 = 0x00000000; //Pin selection for GPIO.
IO0DIR = 0X00000005; //Pin dir. for output-1/input-input
IO0DIR = 0XF0000000;
Arm_Uart0_Init();
}
void main()
{
ARM_INIT();
while(1)
{
IO0PIN=0x00000000;
while((IO0PIN & 0x000F0000) == 0x000F0000);
IO0PIN=0x00000000;
IO0PIN=0xE0000000;
if(( IO0PIN & 0x000F0000 )!= 0x000F0000)
{
switch(IO0PIN & 0x000F0000)
{
case 0x00070000 : serial_tr(‘F’);break;
case 0x000B0000 : serial_tr(‘B’);break;
case 0x000D0000 : serial_tr(‘7’);break;
case 0x000E0000 : serial_tr(‘3’);break;
}
}
IO0PIN=0xD0000000;
if(( IO0PIN & 0x000F0000 )!= 0x000F0000)
{
switch(IO0PIN & 0x000F0000)
{
case 0x00070000 : serial_tr(‘E’);break;
case 0x000B0000 : serial_tr(‘A’);break;
case 0x000D0000 : serial_tr(‘6’);break;
case 0x000E0000 : serial_tr(‘2’);break;
}
}
IO0PIN=0xB0000000;
if(( IO0PIN & 0x000F0000 )!= 0x0F000000)
{
switch(IO0PIN & 0x000F0000)
{
case 0x00070000 : serial_tr(‘D’);break;
case 0x000B0000 : serial_tr(‘9’);break;
case 0x000D0000 : serial_tr(‘5’);break;
case 0x000E0000 : serial_tr(‘1’);break;
}
}
IO0PIN=0x70000000;
if(( IO0PIN & 0x000F0000 )!= 0x000F0000)
{
switch(IO0PIN & 0x000F0000)
{
case 0x00070000 : serial_tr(‘C’);break;
case 0x000B0000 : serial_tr(‘8’);break;
case 0x000D0000 : serial_tr(‘4’);break;
case 0x000E0000 : serial_tr(‘0’);break;
}
}
delay_ms();
}
}
Please Help …:frowning: