Yahoo Groups archive

Lpc2000

Index last updated: 2026-04-28 23:31 UTC

Thread

How to define 2 IRQs

How to define 2 IRQs

2005-03-17 by tphatrapornnant

Hi all,

I have an IRQ problem. My program did not jump after interrupt 
occured. Now I'm using 2 IRQs (I don't want to use FIQ) and I assign 
IRQ 0 for Timer1 and IRQ 1 for Timer0.

VICIntSelect = 0

For Timer1:

VICIntEnable |= 0x00000020;
VICVectAddr = (unsigned long)Func_A;
VICVectCntl0 = 0x25;

For Timer0:

VICVectAddr = (unsigned long)Func_B;
VICVectCntl0 = 0x24;
VICIntEnable |= 0x00000010; 

In simulator, the addresses of Func_A and Func_B were loaded in 
vector table properly. But when interrupt occured (RawInt = 1), the 
program didn't jump to those function. I think my Startup.s is not 
correct. I don't know how to define addresses of 2 function for IRQs.

-------------------------------------------
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, FIQ_Addr

Reset_Addr:     .word   Reset_Handler
Undef_Addr:     .word   Undef_Handler
SWI_Addr:       .word   SWI_Handler
PAbt_Addr:      .word   PAbt_Handler
DAbt_Addr:      .word   DAbt_Handler
                .word   0                      /* Reserved Address */
IRQ_Addr:       .word   IRQ_Handler
FIQ_Addr:       .word   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

------------------------------------------------

It seems program always jump to IRQ_Handler address. If I assign 
Func_A to IRQ_Handler

IRQ_Handler:    B       Func_B

Program will jump to Func_B when interrupt occurs. I used to hook 
these 2 function with FIQ and IRQ Handler. It worked well. But for 2 
IRQs, I don't know how to define them.


Does anyone know can help me?

Thanks,

Teera.

Re: [lpc2000] How to define 2 IRQs

2005-03-17 by Robert Adsett

At 07:03 PM 3/17/05 +0000, tphatrapornnant wrote:
>I have an IRQ problem. My program did not jump after interrupt
>occured. Now I'm using 2 IRQs (I don't want to use FIQ) and I assign
>IRQ 0 for Timer1 and IRQ 1 for Timer0.

<snip>

>In simulator, the addresses of Func_A and Func_B were loaded in
>vector table properly. But when interrupt occured (RawInt = 1), the
>program didn't jump to those function. I think my Startup.s is not
>correct. I don't know how to define addresses of 2 function for IRQs.

<snip>
>It seems program always jump to IRQ_Handler address. If I assign
>Func_A to IRQ_Handler
>
>IRQ_Handler:    B       Func_B
>
>Program will jump to Func_B when interrupt occurs. I used to hook
>these 2 function with FIQ and IRQ Handler. It worked well. But for 2
>IRQs, I don't know how to define them.
<snip>

 From a quick look, I think you are correct.  The IRQ in startup.s needs to 
read the vector from the VIC and jump to it.  I think there are examples in 
the files section.  I know that the newlib-lpc  at 
http://www.aeolusdevelopment.com has a GNU startup that has this routine in 
it (it's really just a different type of jump instruction in the table).

The interrupt routines for each of your Func_A and Func_B above need to be 
defined with your compilers equivalent of an interrupt keyword (if you 
trust it) or have a small assembly shell to take care of the necessary details.

BTW if you don't read and write to the VIC address register the 
corresponding interrupt won't be dismissed.

Robert

" 'Freedom' has no meaning of itself.  There are always restrictions,   be 
they legal, genetic, or physical.  If you don't believe me, try to chew a 
radio signal. "  -- Kelvin Throop, III
http://www.aeolusdevelopment.com/

Re: How to define 2 IRQs

2005-03-21 by tphatrapornnant

Thanks for the link. I'll check it.

Teera.

--- In lpc2000@yahoogroups.com, Robert Adsett <subscriptions@a...>
wrote:
Show quoted textHide quoted text
> At 07:03 PM 3/17/05 +0000, tphatrapornnant wrote:
> >I have an IRQ problem. My program did not jump after interrupt
> >occured. Now I'm using 2 IRQs (I don't want to use FIQ) and I
assign
> >IRQ 0 for Timer1 and IRQ 1 for Timer0.
>
> <snip>
>
> >In simulator, the addresses of Func_A and Func_B were loaded in
> >vector table properly. But when interrupt occured (RawInt = 1), the
> >program didn't jump to those function. I think my Startup.s is not
> >correct. I don't know how to define addresses of 2 function for
IRQs.
>
> <snip>
> >It seems program always jump to IRQ_Handler address. If I assign
> >Func_A to IRQ_Handler
> >
> >IRQ_Handler: B Func_B
> >
> >Program will jump to Func_B when interrupt occurs. I used to hook
> >these 2 function with FIQ and IRQ Handler. It worked well. But for
2
> >IRQs, I don't know how to define them.
> <snip>
>
> From a quick look, I think you are correct. The IRQ in startup.s
needs to
> read the vector from the VIC and jump to it. I think there are
examples in
> the files section. I know that the newlib-lpc at
> http://www.aeolusdevelopment.com has a GNU startup that has this
routine in
> it (it's really just a different type of jump instruction in the
table).
>
> The interrupt routines for each of your Func_A and Func_B above
need to be
> defined with your compilers equivalent of an interrupt keyword (if
you
> trust it) or have a small assembly shell to take care of the
necessary details.
>
> BTW if you don't read and write to the VIC address register the
> corresponding interrupt won't be dismissed.
>
> Robert
>
> " 'Freedom' has no meaning of itself. There are always
restrictions, be
> they legal, genetic, or physical. If you don't believe me, try to
chew a
> radio signal. " -- Kelvin Throop, III
> http://www.aeolusdevelopment.com/

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.