At 04:31 PM 9/2/04 +0000, you wrote:
>i'm new in programming µc but i have some skills in c programming.
>i read in the user manual of the lpc 2124 all about the vic how to
>set the variables. but i do not understand how and where i can
>programm my fiq- or irq-isr in c-code. for the irq-interrupts there
>are the addressregisters, but not for the fiq. so where does it jump?
>how can i programm in c that here is the start-address and the
>interrupt jumps in this function?
First let's deal with the interrupt architecture. The basic response to
exceptions is a table containing jump instructions at the start of the
address space. This includes entries for reset, fiq and irq. The reset
and fiq slots usually contain simple jumps to the service routines (the
assembler startup code for reset). For the fiq that's really all there is
to it. The service routine then has to take care of all the usual
interrupt acknowledgement and care and feeding of any registers affected by
the routine.
The irq is different, and it varies from manufacturer to manufacturer on
the ARM. For the LPC2000 family it uses the VIC which can be programmed to
route each interrupt source to a different service routine. The jump
instruction then normally used for the irq reads the address of the service
routine from the vic and uses it as the address to jump to for the service
routine. The irq then, like the fiq, must deal with the interrupt. In
addition it must clear the interrupt from the VIC.
Finally the fiq (since it's meant to be fast) can be set up in a fashion
where the routine simple continues on from the exception vector location
without needing to perform a jump. Useful if you need a fast interrupt
response of only a few instructions.
Now most (all?) ARM C compilers do include an interrupt keywork to tag a
routine as an interrupt service routine which (if they are not buggy, and
at least some versions of GCC have a bug in this area) take care of the
preserving of registers used by the routine, but all the rest of the
housekeeping still needs to be done. Myself, I've given up on trusting
compilers to do this job "properly". I've been bitten too many times. So I
write my own assembly shells to take care of the appropriate overhead. If
the routines are small I will usually stay in assembly but for larger
routines I use the shell to take care of setting up for a C call.
I've an example of this approach (interrupt shell as well as VIC setup) in
the most recent release of the newlib-lpc code (
http://www.aeolusdevelopment.com/Articles/download.html with documentation
at http://www.aeolusdevelopment.com/Articles/docandapp.html ). It's
passably commented so you should be able to follow it.
I believe that there are examples using the interrupt keyword in the files
section.
>isn't it possible?
>i only found some examples here in assembler, but i do not understand
>it.
Part of understanding a micro (particularly an embedded micro) is learning
enough assembler to at least follow what is happening. It's part of the
steepness of the learning curve but it pays off when you need something
particular done of worse if you need to prove a compiler bug. The good
news is that once you've learned your first few the rest are usually easier
to pick up.
Oh and don't forget that you need to enable interrupts in several places
depending on the source and what is servicing them.
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, IIIMessage
Re: [lpc2000] handle an interrupt with c-code
2004-09-02 by Robert Adsett
Attachments
- No local attachments were found for this message.