Interrupt Performance Characteristics of Arm and Fpga
Interrupt Performance Characteristics of Arm and Fpga
PROGRAM:
#include <LPC214x.H>
#define CR 0x0D
#define PLOCK 0x400
/* Function Prototypes */
unsigned int count=0,count1,Flag = 0;
unsigned char
CSLSB0,CSLSB1,CSLSB2,CSLSB3,CSLSB4,CSLSB5,CSLSB6,CSLSB7,CSLSB8;
//#include <stdio.h>
long int volatile EINT1 = 0;
long int volatile EINT2 = 0;
void ExtInt_Serve1(void)__irq;
void ExtInt_Serve2(void)__irq;
#define PRESCALE 60000
void PLLInit(void)
{
unsigned long loop_ctr;
PLL1CFG = 0x00000024;
PLL1CON = 0x01;
PLL1FEED = 0xAA;
PLL1FEED = 0x55;
loop_ctr = 10000;
while (((PLL1STAT<<10) == 0) && (loop_ctr > 0))
{
loop_ctr--;
}
PLL1CON = 0x02;
PLL1FEED = 0xA0;
PLL1FEED = 0x55;
VPBDIV = 0x01;
}
for(i=0;i<count;i++)
{
for(j=0;j<1000;j++);
}
}
static void feed(void)
{
PLL0FEED = 0xAA;
PLL0FEED = 0x55;
}
void PLL_Init()
{
PLL0CFG = 0x24;
feed();
PLL0CON = 0x01;
feed();
while(!(PLL0STAT & PLOCK));
PLL0CON = 0x3;
feed();
MAMTIM = 0x04;
MAMCR = 0x02;
VPBDIV = 0x01;
}
void UART0_Init()
{
PINSEL0 |= 0x05;
U0LCR = 0x83;
U0DLL = 0x86;
U0DLM = 0x01;
U0LCR = 0x03;
VPBDIV = 0x01;
}
/*Get_Char*/
unsigned char Get_Char(void)
{
while (!(U0LSR&0x01));
return U0RBR;
}
/*Send_Char*/
unsigned char Send_Char(unsigned char ch)
{
if (ch == '\n')
{
while(!(U0LSR & 0x20));
U0THR = CR;
}
while(!(U0LSR & 0x20));
PLL1FEED = 0xA0;
PLL1FEED = 0x55;
VPBDIV = 0x01;
}
void ExtInt_Serve1(void)__irq
{
++EINT1;
EXTINT |= 2;
VICVectAddr = 1;
}
void ExtInt_Serve2(void)__irq
{
++EINT2;
EXTINT |= 4;
VICVectAddr = 0;
}
void ExtInt_Init2(void)
{
EXTMODE |= 4;
EXTPOLAR = 0;
PINSEL0 |= 0x80000000;
VICVectCntl1 = 0x20 | 16;
VICVectAddr1 = (unsigned long) ExtInt_Serve2;
VICIntEnable |= 1<<16;
}
void ExtInt_Init1(void)
{
EXTMODE |= 2;
EXTPOLAR = 0;
PINSEL0 |= 0x20000000;
VICVectCntl0 = 0x20 | 15; //
VICVectAddr0 = (unsigned long) ExtInt_Serve1;
VICIntEnable |= 1<<15;
}
void Serial_Init(void)
{
PINSEL0 |= 0X00000005;
U0LCR = 0x00000083;
U0DLL = 0x00000061;
U0LCR = 0x00000003;
}
void DelayMs(unsigned int count)
{
unsigned int i,j;
for(i=0;i<count;i++)
{
for(j=0;j<1000;j++);
}
}
int main(void)
{
PLLInit();
Serial_Init();
ExtInt_Init1();
ExtInt_Init2();
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);
}
}