EmbeddedRelated.com
Forums

LPC2368 with VIC

Started by Unknown May 10, 2007
hello,everybody.
I am a rookie of lpc2000.I read the code of the Http demo currently,which downloaded from the nxp website.when i come to the irq.c file for MCB2300,I find a function named "install_irq" is differ from the same function in the irq.c file for MCB 2100.The difference puzzled me .I don't know why?Any suggestion is very appreciated.
Both code are shown below.
install_irq ----MCB2300
/******************************************************************************
** Function name: install_irq
**
** Descriptions: Install interrupt handler
** parameters: Interrupt number, interrupt handler address,
** interrupt priority
** Returned value: true or false, return false if IntNum is out of range
**
******************************************************************************/
DWORD install_irq( DWORD IntNumber, void *HandlerAddr, DWORD Priority )
{
DWORD *vect_addr;
DWORD *vect_cntl;

VICIntEnClr = 1 << IntNumber; /* Disable Interrupt */
if ( IntNumber >= VIC_SIZE )
{
return ( FALSE );
}
else
{
/* find first un-assigned VIC address for the handler */
vect_addr = (DWORD *)(VIC_BASE_ADDR + VECT_ADDR_INDEX + IntNumber*4);
vect_cntl = (DWORD *)(VIC_BASE_ADDR + VECT_CNTL_INDEX + IntNumber*4);
*vect_addr = (DWORD)HandlerAddr; /* set interrupt vector */
*vect_cntl = Priority;
VICIntEnable = 1 << IntNumber; /* Enable Interrupt */
return( TRUE );
}
}

irq.c ----MCB2100
/******************************************************************************
** Function name: install_irq
**
** Descriptions: Install interrupt handler
** The max VIC size is 16, but, there are 32 interrupt
** request inputs. Not all of them can be installed into
** VIC table at the same time.
** The order of the interrupt request installation is
** first come first serve.
** parameters: Interrupt number and interrupt handler address
** Returned value: true or false, when the table is full, return false
**
******************************************************************************/
DWORD install_irq( DWORD IntNumber, void *HandlerAddr )
{
DWORD i;
DWORD *vect_addr;
DWORD *vect_cntl;

VICIntEnClr = 1 << IntNumber; /* Disable Interrupt */

for ( i = 0; i < VIC_SIZE; i++ )
{
/* find first un-assigned VIC address for the handler */
vect_addr = (DWORD *)(VIC_BASE_ADDR + VECT_ADDR_INDEX + i*4);
vect_cntl = (DWORD *)(VIC_BASE_ADDR + VECT_CNTL_INDEX + i*4);
if ( *vect_addr == (DWORD)NULL )
{
*vect_addr = (DWORD)HandlerAddr; /* set interrupt vector */
*vect_cntl = (DWORD)(IRQ_SLOT_EN | IntNumber);
break;
}
}
if ( i == VIC_SIZE )
{
return( FALSE ); /* fatal error, can't find empty vector slot */
}
VICIntEnable = 1 << IntNumber; /* Enable Interrupt */
return( TRUE );
}

_______________________________________
ӭʹoacute;
http://cn.mail.yahoo.com

An Engineer's Guide to the LPC2100 Series

---- Original Message ----
From: "Ӷ 刘"
To:
Sent: Thursday, May 10, 2007 6:41 PM
Subject: [lpc2000] LPC2368 with VIC

> I am a rookie of lpc2000.I read the code of the Http demo
> currently,which downloaded from the nxp website.when i come to the
> irq.c file for MCB2300,I find a function named "install_irq" is
> differ from the same function in the irq.c file for MCB 2100.The
> difference puzzled me .I don't know why?Any suggestion is very
> appreciated.

The VIC interrupt controllers are actually different. Compare the manuals,
and check this application note about the differences from LPC21xx/22xx to
LPC23xx/24xx.
http://www.standardics.nxp.com/support/documents/microcontrollers/pdf/an10576.pdf

Karl Olsen