Yahoo Groups archive

Lpc2000

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

Message

Re: C question

2006-03-15 by elektrknight

Hi,

__irq is telling the compiler that the  "void ADC0Handler (void)" is 
not an ordinary function that you can call but an interrupt handler.
Typically interrupt handlers are getting called in response to some
hardware event, in this case the ADC0Handler will service interrupts
generated by the ADC0 unit.  If you follow the code you will notice
that the  ADC0Handler is installed as the irq handler by the
install_irq function called by the ADCInit. If you are curious, you
will notice that install_irq takes address of the ADC0Handler and
stuffs it into an empty  slot in VIC (Vector Interrupt Handler)
associating it with the interrupt number (channel) corresponding to
the ADC0 unit.

 So the question is how does the ADC0Handler gets called if it is
never called directly from the code?  Consider the situation when ADC0
is done with the A/D conversion and wants attention from the CPU.  To
get it,  ADC  asks VIC to generate interrupt on VIC channel ADC0_INT ,
in turn VIC will look through all of the slots for a matching handler.
 If it finds one it will then interrupt the CPU and make it jump to
the address in the slot which in this case will be ADC0Handler! 

 Since, the interrupt handler can be called at any time the compiler
needs to know that to generate code that is a bit different then for
the normal functions and __irq is doing that. 

 I hope this will help you a bit but this is just a beginning and as
always devil is in (a lot of) details that I did not mention. If you
want to learn more check  ARM  and Philips  documentation, look for
exception handling and interrupts. 

thanks,
elektrknight




--- In lpc2000@yahoogroups.com, "heedaf" <ruffellfamily@...> wrote:
>
> I have a newbie question.  In the following code
>  
>     void ADC0Handler (void) __irq
>  
> What does __irq do?  I've never seen this before.  It comes from the 
> Kiel ADC sample listed Philips website.
> Thanks,
> Dewayne
>

Attachments

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.