Interrupt works in Keil simulator but not in target
2003-12-10 by helgefh2003
Yahoo Groups archive
Index last updated: 2026-04-28 23:31 UTC
Thread
2003-12-10 by helgefh2003
Hi, -------------------------------------- The example project from Keil running Timer0 as interrupt source, works in the simulator but in the target there is never an interrupt generated. Rewriting it, polling the interrupt flag works both in the simulator and the target. http://www.keil.com/download/files/lpc2100_blinky.zip Chip used is LPC2106. Anyone having a clue? //Helge
2003-12-10 by Curt Powell
Helge, Keil uses gnu, correct? There is an issue with the interrupt keyword in earlier versions of gnu compiler. Are you aware of this? The workaround is to call an assembler ISR which in turn calls the C function. Could this be your problem? Curt
-----Original Message----- From: helgefh2003 [mailto:helge.fabricius@...] Sent: Wednesday, December 10, 2003 7:18 AM To: lpc2100@yahoogroups.com Subject: [lpc2100] Interrupt works in Keil simulator but not in target Hi, -------------------------------------- The example project from Keil running Timer0 as interrupt source, works in the simulator but in the target there is never an interrupt generated. Rewriting it, polling the interrupt flag works both in the simulator and the target. http://www.keil.com/download/files/lpc2100_blinky.zip Chip used is LPC2106. Anyone having a clue? //Helge Yahoo! Groups Sponsor ADVERTISEMENT <http://rd.yahoo.com/SIG=12cclbrkg/M=267637.4116732.5333197.1261774/D=eg roupweb/S=1706554205:HM/EXP=1071156002/A=1853618/R=0/*http://www.netflix .com/Default?mqso=60178338&partid=4116732> click here <http://us.adserver.yahoo.com/l?M=267637.4116732.5333197.1261774/D=egrou pmail/S=:HM/A=1853618/rand=896117642> To unsubscribe from this group, send an email to: lpc2100-unsubscribe@yahoogroups.com Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .
2003-12-10 by Helge Fabricius-Hansen
Strange thing is that it work in the simulator... And I suppose that the program would crash if there is a vector/jump address fault. The rest of the program works just fine. But I will give it a try... //Helge --- In lpc2100@yahoogroups.com, "Curt Powell" <curt.powell@s...> wrote: > Helge, > > Keil uses gnu, correct? There is an issue with the interrupt keyword in > earlier versions of gnu compiler. Are you aware of this? The > workaround is to call an assembler ISR which in turn calls the C > function. Could this be your problem? > > Curt > > -----Original Message----- > From: helgefh2003 [mailto:helge.fabricius@t...] > Sent: Wednesday, December 10, 2003 7:18 AM > To: lpc2100@yahoogroups.com > Subject: [lpc2100] Interrupt works in Keil simulator but not in target > > > Hi, > -------------------------------------- > The example project from Keil running Timer0 as interrupt source, > works in the simulator but in the target there is never an interrupt > generated. Rewriting it, polling the interrupt flag works both in > the simulator and the target. > > http://www.keil.com/download/files/lpc2100_blinky.zip > > Chip used is LPC2106. > > Anyone having a clue? > > //Helge > > > > Yahoo! Groups Sponsor > > ADVERTISEMENT > > <http://rd.yahoo.com/SIG=12cclbrkg/M=267637.4116732.5333197.1261774/D =eg > roupweb/S=1706554205:HM/EXP=1071156002/A=1853618/R=0/*http://www.netf lix > .com/Default?mqso=60178338&partid=4116732> click here > > <http://us.adserver.yahoo.com/l? M=267637.4116732.5333197.1261774/D=egrou
> pmail/S=:HM/A=1853618/rand=896117642> > > To unsubscribe from this group, send an email to: > lpc2100-unsubscribe@yahoogroups.com > > > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service > <http://docs.yahoo.com/info/terms/> .
2003-12-10 by Hugh O'Keeffe
Hi, I can confirm problems with GNU ARM interrupt keyword in versions v3.3.1 and previous. See bugzilla http://gcc.gnu.org/ml/gcc-bugs/2003-10/msg01184.html for the gory details. The workaround is that you need to do your context save/restore in assembler before branching to the "C" interrupt handler function (rather than depending on the GNU compiler to do this when it sees the "interrupt" keyword. Ashling customers can download a GNU example that shows how to do TIMER0 interrupts from our FAQ page as shown in the below link. The program toggles a LED that is specific to Ashling's LPC2100 EVBA7 board. Leon, I'm prepared to give you the source code to allow you to adapt it to your own board and post it on your site if you like. Email me directly. All the code is GNU, however, the build is done using our IDE (AsIDE). Hugh @ http://www.ashling.com/support/lpc2100/
-----Original Message----- From: Curt Powell [mailto:curt.powell@...] Sent: 10 December 2003 16:18 To: lpc2100@yahoogroups.com Subject: RE: [lpc2100] Interrupt works in Keil simulator but not in target Helge, Keil uses gnu, correct? There is an issue with the interrupt keyword in earlier versions of gnu compiler. Are you aware of this? The workaround is to call an assembler ISR which in turn calls the C function. Could this be your problem? Curt -----Original Message----- From: helgefh2003 [mailto:helge.fabricius@...] Sent: Wednesday, December 10, 2003 7:18 AM To: lpc2100@yahoogroups.com Subject: [lpc2100] Interrupt works in Keil simulator but not in target Hi, -------------------------------------- The example project from Keil running Timer0 as interrupt source, works in the simulator but in the target there is never an interrupt generated. Rewriting it, polling the interrupt flag works both in the simulator and the target. http://www.keil.com/download/files/lpc2100_blinky.zip Chip used is LPC2106. Anyone having a clue? //Helge To unsubscribe from this group, send an email to: lpc2100-unsubscribe@yahoogroups.com Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> . Yahoo! Groups Sponsor ADVERTISEMENT <http://rd.yahoo.com/SIG=12cafvjm5/M=267637.4116730.5333196.1261774/D=eg roupweb/S=1706554205:HM/EXP=1071159512/A=1853618/R=0/*http://www.netflix .com/Default?mqso=60178338&partid=4116730> click here <http://us.adserver.yahoo.com/l?M=267637.4116730.5333196.1261774/D=egrou pmail/S=:HM/A=1853618/rand=592458958> To unsubscribe from this group, send an email to: lpc2100-unsubscribe@yahoogroups.com Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .
2003-12-10 by Michael Pont
Helge, Which version of GCC are you using? If you are using >= 3.31, you should not need the assembly-language interrupt harness (if you are using a version before this, you will need the harness). Michael. > From: "Helge Fabricius-Hansen" <helge.fabricius@...> > Date: 2003/12/10 Wed PM 04:43:36 GMT > To: lpc2100@yahoogroups.com > Subject: [lpc2100] Re: Interrupt works in Keil simulator but not in target > > Strange thing is that it work in the simulator... > And I suppose that the program would crash if there is a vector/jump > address fault. The rest of the program works just fine. > But I will give it a try... > > //Helge > +======================================+ Michael J. Pont, PhD Embedded Systems Laboratory, University of Leicester http://www.le.ac.uk/eg/embedded +======================================+
2003-12-10 by Curt Powell
Helge, It worked in my Ashling development environment for a few hundred interrupts, then the program would jump to never-never land. Curt
-----Original Message----- From: Helge Fabricius-Hansen [mailto:helge.fabricius@...] Sent: Wednesday, December 10, 2003 8:44 AM To: lpc2100@yahoogroups.com Subject: [lpc2100] Re: Interrupt works in Keil simulator but not in target Strange thing is that it work in the simulator... And I suppose that the program would crash if there is a vector/jump address fault. The rest of the program works just fine. But I will give it a try... //Helge --- In lpc2100@yahoogroups.com, "Curt Powell" <curt.powell@s...> wrote: > Helge, > > Keil uses gnu, correct? There is an issue with the interrupt keyword in > earlier versions of gnu compiler. Are you aware of this? The > workaround is to call an assembler ISR which in turn calls the C > function. Could this be your problem? > > Curt > > -----Original Message----- > From: helgefh2003 [mailto:helge.fabricius@t...] > Sent: Wednesday, December 10, 2003 7:18 AM > To: lpc2100@yahoogroups.com > Subject: [lpc2100] Interrupt works in Keil simulator but not in target > > > Hi, > -------------------------------------- > The example project from Keil running Timer0 as interrupt source, > works in the simulator but in the target there is never an interrupt > generated. Rewriting it, polling the interrupt flag works both in > the simulator and the target. > > http://www.keil.com/download/files/lpc2100_blinky.zip > > Chip used is LPC2106. > > Anyone having a clue? > > //Helge > > > > Yahoo! Groups Sponsor > > ADVERTISEMENT > > <http://rd.yahoo.com/SIG=12cclbrkg/M=267637.4116732.5333197.1261774/D =eg > roupweb/S=1706554205:HM/EXP=1071156002/A=1853618/R=0/*http://www.netf lix > .com/Default?mqso=60178338&partid=4116732> click here > > <http://us.adserver.yahoo.com/l? M=267637.4116732.5333197.1261774/D=egrou > pmail/S=:HM/A=1853618/rand=896117642> > > To unsubscribe from this group, send an email to: > lpc2100-unsubscribe@yahoogroups.com > > > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service > <http://docs.yahoo.com/info/terms/> . Yahoo! Groups Sponsor <http://rd.yahoo.com/SIG=12c9t832h/M=259395.3614674.4902533.1261774/D=eg roupweb/S=1706554205:HM/EXP=1071161281/A=1524963/R=0/*http://hits.411web .com/cgi-bin/autoredir?camp=556&lineid=3614674&prop=egroupweb&pos=HM> <http://us.adserver.yahoo.com/l?M=259395.3614674.4902533.1261774/D=egrou pmail/S=:HM/A=1524963/rand=675410731> To unsubscribe from this group, send an email to: lpc2100-unsubscribe@yahoogroups.com Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .
2003-12-10 by Helge Fabricius-Hansen
Hi, I am using 3.31 of the GCC so the problem is there. Still I don't understand why the program is working OK except for the interrupt. Should the program not crash when it generates the interrupt... Helge --- In lpc2100@yahoogroups.com, Michael Pont <Michael.Pont@t...> wrote: > > Helge, > > Which version of GCC are you using? > > If you are using >= 3.31, you should not need the assembly- language interrupt harness (if you are using a version before this, you will need the harness). > > Michael. > > > From: "Helge Fabricius-Hansen" <helge.fabricius@t...> > > Date: 2003/12/10 Wed PM 04:43:36 GMT > > To: lpc2100@yahoogroups.com > > Subject: [lpc2100] Re: Interrupt works in Keil simulator but not in target > > > > Strange thing is that it work in the simulator... > > And I suppose that the program would crash if there is a vector/jump
> > address fault. The rest of the program works just fine. > > But I will give it a try... > > > > //Helge > > > > > +======================================+ > > Michael J. Pont, PhD > Embedded Systems Laboratory, > University of Leicester > > http://www.le.ac.uk/eg/embedded > > +======================================+
2003-12-10 by Michael Pont
> If you are using >= 3.31, you should not need the > assembly-language interrupt harness (if you are using a > version before this, you will need the harness). I'm going to reply to my own post (and be a little more specific...). When programming in C, I prefer to use ISRs without an assembly-language harness. With 3.3.1 you can - in my (thus far fairly limited) experience with this compiler - get away with this. This was not possible with previous versions of GCC that I have tried. However, this only applies *** with simple ISRs ***. With non-trivial ISRS (including, for example, function calls) we've run into problems. If I understand the GCC bug reports correctly, this bug may be fixed in GCC 3.4, sometime next year? At present, I've gone back to use assembly-language harnesses for all my ISRs. Michael. +======================================+ Michael J. Pont, PhD Embedded Systems Laboratory, University of Leicester http://www.le.ac.uk/eg/embedded +======================================+
2003-12-10 by leon_heller
--- In lpc2100@yahoogroups.com, "Hugh O'Keeffe" <hugh.okeeffe@a...> wrote: > Hi, > > I can confirm problems with GNU ARM interrupt keyword in versions v3.3.1 > and previous. See bugzilla > http://gcc.gnu.org/ml/gcc-bugs/2003-10/msg01184.html for the gory > details. > > The workaround is that you need to do your context save/restore in > assembler before branching to the "C" interrupt handler function (rather > than depending on the GNU compiler to do this when it sees the > "interrupt" keyword. > > Ashling customers can download a GNU example that shows how to do TIMER0 > interrupts from our FAQ page as shown in the below link. The program > toggles a LED that is specific to Ashling's LPC2100 EVBA7 board. > > Leon, I'm prepared to give you the source code to allow you to adapt it > to your own board and post it on your site if you like. Email me > directly. All the code is GNU, however, the build is done using our IDE The Rowley Associates tools come with an example that shows how to do this with the Nohau board. It works with my board, with an LED connected appropriately. Leon
2003-12-10 by microbit
> However, this only applies *** with simple ISRs ***. With non-trivial ISRS (including, for example, function calls) > we've run into problems. If I understand the GCC bug reports correctly, this bug may be fixed in GCC 3.4, sometime next year? > > At present, I've gone back to use assembly-language harnesses for all my ISRs. Bizarre, I've been using the HITECH-C compiler with HITide and you can do even Call back functions from ISR fully in C ??? There is one ASM file to do vector definition, but I think that can be with a macro. Didn't get there yet though. -- Kris
2003-12-10 by Bill Knight
On Wed, 10 Dec 2003 18:12:28 +0000, Michael Pont wrote:
> If you are using >= 3.31, you should not need the
> assembly-language interrupt harness (if you are using a
> version before this, you will need the harness).
I'm going to reply to my own post (and be a little more specific...).
When programming in C, I prefer to use ISRs without an assembly-language harness. With 3.3.1 you can - in my (thus far fairly limited) experience with this compiler - get away with this. This was not possible with previous versions of GCC that I have tried.
However, this only applies *** with simple ISRs ***. With non-trivial ISRS (including, for example, function calls) we've run into problems. If I understand the GCC bug reports correctly, this bug may be fixed in GCC 3.4, sometime next year?
At present, I've gone back to use assembly-language harnesses for all my ISRs.
I believe you can code the interrupt ISR in C if the ONLY thing you
do in the ISR function is call a function that actually does the
work. It does require an extra level of call. Hmmm, I wonder if
it were marked 'inline'...
Regards
-Bill Knight
R O SoftWare
// this 'work' function is NOT coded as an interrupt
void workISR(void)
{
// do whatever is required here to service the interrupt
}
// this function has the interrupt attribute
void xxxISR(void)
{
workISR();
}2003-12-10 by leon_heller
--- In lpc2100@yahoogroups.com, "microbit" <microbit@c...> wrote: > > However, this only applies *** with simple ISRs ***. With non-trivial > ISRS (including, for example, function calls) > > we've run into problems. If I understand the GCC bug reports correctly, > this bug may be fixed in GCC 3.4, sometime next year? > > > > At present, I've gone back to use assembly-language harnesses for all my > ISRs. > > Bizarre, I've been using the HITECH-C compiler with HITide and you can do > even > Call back functions from ISR fully in C ??? > There is one ASM file to do vector definition, but I think that can be with > a macro. > Didn't get there yet though. > HiTech wrote their own compiler, didn't they? Leon
2003-12-11 by lpc2100
Replace your irq handler with the following code.
This example uses VIC. I hope you can figure out how to program the
VIC. Do NOT use the gnu "interrupt" keyword in your C function. You
also need to program the VIC address registers with the appropriate C
function handler addresses.
irq_handler:
/* save return address and work regs on stack */
/* save r0-r4,lr,r12 on stack remaining regs */
/* are saved by the c function if used */
stmfd sp!, { r0-r3,r12,lr }
/* use r1 to save spsr_irq */
mrs r1, spsr
/* save r1 again as per ATPCS r0-r4 & r12 are not saved */
/* by the called function */
stmfd sp!,{r1}
/* setup link register so that the normal c function */
/* which is used as an isr returns to ldmfd sp!,{r1} instruction */
add lr,pc,#0x4
/* Read the ISR address from the VIC */
ldr r0, =0xfffff030
ldr pc,[r0]
/* Restore spsr_irq */
ldmfd sp!,{r1}
msr spsr_cxsf, r1
/* Restore remaining registers
ldmfd sp!, { r0-r3,r12,lr }
/* Resume interrupted execution flow */
subs pc, lr, #0x42003-12-11 by lpc2100
Replace your irq handler with the following code.
This example uses VIC. I hope you can figure out how to program the
VIC. Do NOT use the gnu "interrupt" keyword in your C function. You
also need to program the VIC address registers with the appropriate C
function handler addresses.
irq_handler:
/* save return address and work regs on stack */
/* save r0-r4,lr,r12 on stack remaining regs */
/* are saved by the c function if used */
stmfd sp!, { r0-r3,r12,lr }
/* use r1 to save spsr_irq */
mrs r1, spsr
/* save r1 again as per ATPCS r0-r4 & r12 are not saved */
/* by the called function */
stmfd sp!,{r1}
/* setup link register so that the normal c function */
/* which is used as an isr returns to ldmfd sp!,{r1} instruction */
add lr,pc,#0x4
/* Read the ISR address from the VIC */
ldr r0, =0xfffff030
ldr pc,[r0]
/* Restore spsr_irq */
ldmfd sp!,{r1}
msr spsr_cxsf, r1
/* Restore remaining registers
ldmfd sp!, { r0-r3,r12,lr }
/* Resume interrupted execution flow */
subs pc, lr, #0x42003-12-11 by Helge Fabricius-Hansen
With some help from Reinhard Keil the problem was solved...
Seams like the only thing missing was the acknowledge to the VIC
before leaving the interruptfunction.
To fix the other problem I moved out the code to a function.
void tc0 (void)
{
TimerUpdate();
timeval++;
TIMER0_IR = 1; // Clear interrupt flag
-> VICVectAddr = 0; // Acknowledge Interrupt
}
Thanks everyone...
--- In lpc2100@yahoogroups.com, "helgefh2003" <helge.fabricius@t...>
wrote:
> Hi,
> --------------------------------------
> The example project from Keil running Timer0 as interrupt source,
> works in the simulator but in the target there is never an
interrupt > generated. Rewriting it, polling the interrupt flag works both in > the simulator and the target. > > http://www.keil.com/download/files/lpc2100_blinky.zip > > Chip used is LPC2106. > > Anyone having a clue? > > //Helge
2004-02-11 by Soeren Gust
I know that the original message is quite old, but I just spent several
hours trying to get it to work and finally found that the problem is a
missing closing comment. So the restoring ldmfd instruction never gets
executed, the calling address in lr still points inside the handler
which gives a nice endless loop. It will also fill up the interrupt
stack.
I also have a hint to other beginners on ARM processors: they have
several stacks, you need to initialize all you want to use. There is an
example on how to do this for the IRQ and FIQ stack in the application
note AN10254 on the Philips web site.
On Thu, Dec 11, 2003 at 03:39:18AM -0000, somebody wrote:
> Replace your irq handler with the following code.
> This example uses VIC. I hope you can figure out how to program the
> VIC. Do NOT use the gnu "interrupt" keyword in your C function. You
> also need to program the VIC address registers with the appropriate C
> function handler addresses.
>
> irq_handler:
>
> /* save return address and work regs on stack */
> /* save r0-r4,lr,r12 on stack remaining regs */
> /* are saved by the c function if used */
>
> stmfd sp!, { r0-r3,r12,lr }
>
> /* use r1 to save spsr_irq */
>
> mrs r1, spsr
>
> /* save r1 again as per ATPCS r0-r4 & r12 are not saved */
> /* by the called function */
>
> stmfd sp!,{r1}
>
> /* setup link register so that the normal c function */
> /* which is used as an isr returns to ldmfd sp!,{r1} instruction */
>
> add lr,pc,#0x4
>
> /* Read the ISR address from the VIC */
>
> ldr r0, =0xfffff030
> ldr pc,[r0]
>
> /* Restore spsr_irq */
> ldmfd sp!,{r1}
> msr spsr_cxsf, r1
>
> /* Restore remaining registers
put a */ there ------------------^
> ldmfd sp!, { r0-r3,r12,lr }
>
> /* Resume interrupted execution flow */
> subs pc, lr, #0x4
Soeren Gust2004-02-12 by Stephen Pelc
From: Soeren Gust <gust@...> In terms of increasing UART performance, I agree about not using Thumb, especially as the IRQ entry/exit code must be in ARM. I also agree with the comment about using structures to gain base+offset addressing. 1) Set up the MAM - major impact 2) Consider x2 PLL 3) Set up the UART FCR register to use the FIFOs by interrupting every n characters. This reduces the number of interrupts considerably. You have to poll the LSR in the interrupt routine to empty the FIFO. Don't worry about missing the last few characters, the UART will interrupt after a time if the FIFO is part full. 4) You can reduce the interrupt latency by making the IRQ vector contain: ldr pc, [ pc, # $-FF0 ] which reads the vector address directly. There is a slight cost in that each ISR needs its own entry/exit code. Note also that if you want to nest interrupts, you MUST switch to another mode - SVC is the usual one to use. 2106 boards with a USB connection will be available from MPE in a few weeks. Software will include an on-chip Forth interpreter, evaluation versions of the MPE VFX Forth cross compiler and Rowley Crossworks C compiler, and we may even get round to a BASIC. Stephen -- Stephen Pelc, stephen@... MicroProcessor Engineering Ltd - More Real, Less Time 133 Hill Lane, Southampton SO15 5AF, England tel: +44 23 80 631441, fax: +44 23 80 339691 web: http://www.mpeltd.demon.co.uk - free VFX Forth downloads