EmbeddedRelated.com
Forums

LPC2368 with multiple IRQ and one FIQ

Started by philippeirrien April 3, 2007
Hye,
In my project, i use the lpc2368 chips of nxp.I used the Http demo
software and i modified it for my project.I use the MDK_ARM compiler
with the Keil IDE.
I work for the moment with the MCB2300 evaluation board. I need to use
the following IRQ and FIQ :
-> Irq of the timer 1,
-> Irq of the UART 0,
-> Irq of the UART 1,
-> Fiq on the Ethernet MAC.

With the IRQ timer1 and the FIQ Ehternet MAC, the software of my
project don't crashed.I can access to the http server.
But when the UART0 interruption is installed the software crashed and i
can acces to the http server.

Anybody have sugestion for resolving this problem ?

Best regard
Phil

An Engineer's Guide to the LPC2100 Series

Hello again,

I haven't try use the fiq with your explanation!
anyway with UART1 activated is the same problem?
what is the slot IRQ for
e timer 1, UART 0, UART 1, (do you use all?)
and the fiq for the Ethernet MAC.?
what do you have inside of interruption of UART 0 and how you activate?
is something like this?

PINSEL0 = (PINSEL0 & ~U0_PINMASK) | U0_PINSEL;
U0IER = 0x00; // disable all interrupts
//U0IIR; // clear interrupt ID
//U0RBR; // clear receive register
//U0LSR; // clear line status
register
// set the baudrate
U0LCR = ULCR_DLAB_ENABLE; // select divisor latches
U0DLL = (uint8_t)baud; // set for baud low byte
U0DLM = (uint8_t)(baud >> 8); // set for baud high byte
// set the number of
characters and other
// user specified operating
parameters
U0LCR = (mode & ~ULCR_DLAB_ENABLE);
U0FCR = fifomode;

TIPGRAV_VIC_UART0();
U0IER = UIER_ERBFI; // activate the
interruption of Rx
U0IER |= UIER_ETBEI;

is something like this?

void UART0_interrupt(void){
uint8_t iid;
// loop until not more interrupt sources
while (((iid = U0IIR) & UIIR_NO_INT) == 0){
// identify & process the
highest priority interrupt
switch (iid & UIIR_ID_MASK){
case UIIR_RLS_INT: // Receive Line Status
U0LSR; // read LSR to clear
break;

case UIIR_CTI_INT: // Character Timeout Indicator
case UIIR_RDA_INT: // Receive Data Available

do{
char car;
car = U0RBR;
protocolo_UART0(car);
}while (U0LSR & ULSR_RDR);
break;

case UIIR_THRE_INT: // Transmit Holding
Register Empty
txBufEmpty(); // check if
more data to send

break;
default: // Unknown
U0LSR;
U0RBR;
break;
}
}
VICVectAddr = 0xFF;
}

Regards,
Filipe Santos

philippeirrien wrote:
>
> --- In l... ,
> "santosfilipe" wrote:
> >Hello,
> Thank for you answer.
> I do what you say by increase the size of the two stack but it's the
> same result.for me there is a conflic with the IRQ.May be the VIC
> controller have a problem.Have you one another idea ?
>
> Here the code for the FIQ/IRQ interrupt on LPC23xx :
>
> void Init_VIC( void ) {
>
> U32 i32 = 0;
> U32 *u32VectAddr;
> U32 *u32VectCntl;
>
> /* initialize VIC*/
> VICIntEnClr = 0xffffffff;
> VICVectAddr = 0;
> VICIntSelect = 0;
>
> /* set all the vector and vector control register to 0 */
> for ( i32 = 0; i32 < VIC_SIZE; i32++ )
> {
> u32VectAddr = (U32 *)(VIC_BASE_ADDR + VECT_ADDR_INDEX + i32*4);
> u32VectCntl = (U32 *)(VIC_BASE_ADDR + VECT_CNTL_INDEX + i32*4);
> *u32VectAddr = 0x0;
> *u32VectCntl = 0xF;
> }
> return;
> }
>
> U32 Install_IRQ( U32 u32IntNumber, void *HandlerAddr, U32
> u32Priority ) {
>
> U32 *u32VectAddr;
> U32 *u32VectCntl;
>
> VICIntEnClr = 1 << u32IntNumber; /* Disable Interrupt */
> if ( u32IntNumber >= VIC_SIZE ) {
> return ( __FALSE );
> } else {
> /* find first un-assigned VIC address for the handler */
> VICIntSelect |= (0 << u32IntNumber); /* interrupt is IRQ */
> u32VectAddr = (U32 *)(VIC_BASE_ADDR + VECT_ADDR_INDEX +
> u32IntNumber*4);
> u32VectCntl = (U32 *)(VIC_BASE_ADDR + VECT_CNTL_INDEX +
> u32IntNumber*4);
> *u32VectAddr = (U32)HandlerAddr; /* set interrupt vector */
> *u32VectCntl = u32Priority;
> VICIntEnable = 1 << u32IntNumber; /* Enable Interrupt */
> return( __TRUE );
> }
> }
>
> U32 Install_FIQ( S32 s32IntNumber, void *HandlerAddr, S32
> s32Priority ) {
>
> U32 *u32VicCtrl = (U32 *)(VIC_BASE_ADDR + VECT_CNTL_INDEX);
>
> if ((0 <= s32IntNumber) && (s32IntNumber <= 31) && (-15 <> s32Priority) && (s32Priority <= 15)) {
> VICIntSelect |= (1 << s32IntNumber); /* interrupt is FIQ */
> if (HandlerAddr != (void *)NULL)
> *((U32 *)0x40000018) = (U32)HandlerAddr;
> if (s32Priority >= 0) {
> u32VicCtrl[s32IntNumber] = s32Priority;
> VICIntEnable = (1 << s32IntNumber); /* enable interrupt */
> } else {
> u32VicCtrl[s32IntNumber] = -s32Priority;
> VICIntEnClr = (1 << s32IntNumber); /* clear interrupt enable
> */
> }
> return ( __TRUE );
> } else
> return ( __FALSE );
> }
>
> you needs to initialize the VIC controller and to install each
> handler (IRQ + FIQ) like this :
> Init_VIC();
> Install_FIQ(FIQ, (void *)FIQ_Handler, HIGHEST_PRIORITY);
> Install_IRQ(IRQ, (void *)IRQ_Handler, HIGHEST_PRIORITY);
>
> You also need to modify the startup file.
>
> UND_Stack_Size EQU 0x00000000
> SVC_Stack_Size EQU 0x00000008
> ABT_Stack_Size EQU 0x00000000
> FIQ_Stack_Size EQU 0x00000040
> IRQ_Stack_Size EQU 0x00000100
> USR_Stack_Size EQU 0x00000400
> ...
>
> ;Import Externals symbols declaration
> IMPORT FIQ_Handler ; use external FIQ_Handler
> PRESERVE8 ; tell linker: stack
>
> ; Exception Vectors
> ; Mapped to Address 0.
> ; Absolute addressing mode must be used.
> ; Dummy Handlers are implemented as infinite loops which can be
> modified.
>
> Vectors LDR PC, Reset_Addr
> LDR PC, Undef_Addr
> LDR PC, SWI_Addr
> LDR PC, PAbt_Addr
> LDR PC, DAbt_Addr
> NOP ; Reserved Vector
> ; LDR PC, IRQ_Addr
> LDR PC, [PC, #-0x0120] ; Vector from
> VicVectAddr
> LDR PC, FIQ_Addr
>
> Reset_Addr DCD Reset_Handler
> Undef_Addr DCD Undef_Handler
> SWI_Addr DCD SWI_Handler
> PAbt_Addr DCD PAbt_Handler
> DAbt_Addr DCD DAbt_Handler
> DCD 0 ; Reserved Address
> IRQ_Addr DCD IRQ_Handler
> FIQ_Addr DCD FIQ_Handler
> ...
>
> Undef_Handler B Undef_Handler
> SWI_Handler B SWI_Handler
> PAbt_Handler B PAbt_Handler
> DAbt_Handler B DAbt_Handler
> IRQ_Handler B IRQ_Handler
> ;FIQ_Handler B FIQ_Handler
>
> Regards,
> Philippe Irrien
>
> > Hello,
> >
> > I'm not sure, but have you try to use more memory for the stack of
> IRQ
> > and FIQ, I say this because have the same problem but only with IRQ,
> > and the explanation for this was the use of buffers local and
> internal
> > that needed to be pushed to memory!
> >
> > anyway i'm trying put working fiq on my 2294, so if you have success
> > please give-me the steps for put working one fiq!
> >
> > cheers,
> > Filipe Santos
> >
> > --- In l... ,
> "philippeirrien" wrote:
> > >
> > > Hye,
> > > In my project, i use the lpc2368 chips of nxp.I used the Http
> demo
> > > software and i modified it for my project.I use the MDK_ARM
> compiler
> > > with the Keil IDE.
> > > I work for the moment with the MCB2300 evaluation board. I need
> to use
> > > the following IRQ and FIQ :
> > > -> Irq of the timer 1,
> > > -> Irq of the UART 0,
> > > -> Irq of the UART 1,
> > > -> Fiq on the Ethernet MAC.
> > >
> > > With the IRQ timer1 and the FIQ Ehternet MAC, the software of my
> > > project don't crashed.I can access to the http server.
> > > But when the UART0 interruption is installed the software crashed
> and i
> > > can acces to the http server.
> > >
> > > Anybody have sugestion for resolving this problem ?
> > >
> > > Best regard
> > > Phil
> > >
> >