Reply by Garry Sharpe December 5, 20042004-12-05
Thank you all for your feedback, your comments were much appreciated.

The problem was associated with a bug with the imagecraft compiler apparently.

All code checked out in the generated .lst file and nothing appeared to be wrong however i could still not get an isr to interrupt another isr (ie: when clearing 'I' within an isr) or could not even get an isr to be honoured and executed after the currently executing isr had returned.

Putting a asm(" nop"); just before the code which re-enables the interrupt in each isr fixed the problem.

Dont fully understand why (it made no difference to the code appearing in the .lst file...except for the new instuction).......but it made all the difference.

Thanks again all "Redd, Emmett R" <> wrote:
Do you issue a CLI instruction in your RTI_ISR? The HC11 automatically
sets the I bit in the CCR when an interrupt is called. So if your
RTI_ISR becomes the "main", it is not surprising all other interrupts
are inhibited unless you clear the interrupt bit within it.

Emmett Redd Ph.D. mailto:
Associate Professor (417)836-5221
Department of Physics, Astronomy, and Materials Science
Southwest Missouri State University Fax (417)836-6226
901 SOUTH NATIONAL Dept (417)836-5131
SPRINGFIELD, MO 65804 USA

> -----Original Message-----
> From: Garry Sharpe [mailto:]
> Sent: Saturday, October 23, 2004 1:10 AM
> To:
> Subject: [m68HC11] help ...IC's interrupting an RTI ??? > I am a student that is having trouble getting Input Capture
interrupts
> (IC2 & IC3) to interrupt an RTI.
>
> Basics:
>
> My program, including the RTI, IC2 and IC3 ISR's are written in C
whilst
> all ports, interrupts etc are initiated in assembly. The code is
compiled
> using 'Imagecraft C' and loaded to my E2 chip (in bootstrap) using
> PCBug11.
> (IC2 and IC3 are set for rising and falling edge respectively)
>
> Problem:
>
> My project is designed around a Finite State Model, allowing
> void main(void) to simply contain a few initial setup instructions and
a
> while(1); loop, allowing the RTI to take control of the program
execution.
>
> Both IC2 and IC3 interrupts are detected and their ISR's executed when
I
> disable the RTI and simply call the RTI_ISR(); from main(); as a
simple
> subroutine.
>
> This makes me think there is nothing wrong with the coding and setup
of
> the IC2 and IC3 interrupts, however, When the RTI is operating as a
RTI,
> the IC2 and IC3 interrupts are simply ignored or not even detected, so
> maybe my code is missing something.
>
> Probably a bit hard to understand as my explanation of the situation
is
> probably not the best..sorry, however,
>
> Is there some trick to getting an interrupt to interrupt another
interrupt
> ?
> ie: An IC interrupt to interrupt an RTI
>
> Any feedback on this subject would be greatly appreciated.
> Thankyou

---------------------------------
Yahoo! Groups Links

To

---------------------------------
Find local movie times and trailers on Yahoo! Movies.


Reply by Redd, Emmett R October 25, 20042004-10-25
Do you issue a CLI instruction in your RTI_ISR? The HC11 automatically
sets the I bit in the CCR when an interrupt is called. So if your
RTI_ISR becomes the "main", it is not surprising all other interrupts
are inhibited unless you clear the interrupt bit within it.

Emmett Redd Ph.D. mailto:
Associate Professor (417)836-5221
Department of Physics, Astronomy, and Materials Science
Southwest Missouri State University Fax (417)836-6226
901 SOUTH NATIONAL Dept (417)836-5131
SPRINGFIELD, MO 65804 USA

> -----Original Message-----
> From: Garry Sharpe [mailto:]
> Sent: Saturday, October 23, 2004 1:10 AM
> To:
> Subject: [m68HC11] help ...IC's interrupting an RTI ??? > I am a student that is having trouble getting Input Capture
interrupts
> (IC2 & IC3) to interrupt an RTI.
>
> Basics:
>
> My program, including the RTI, IC2 and IC3 ISR's are written in C
whilst
> all ports, interrupts etc are initiated in assembly. The code is
compiled
> using 'Imagecraft C' and loaded to my E2 chip (in bootstrap) using
> PCBug11.
> (IC2 and IC3 are set for rising and falling edge respectively)
>
> Problem:
>
> My project is designed around a Finite State Model, allowing
> void main(void) to simply contain a few initial setup instructions and
a
> while(1); loop, allowing the RTI to take control of the program
execution.
>
> Both IC2 and IC3 interrupts are detected and their ISR's executed when
I
> disable the RTI and simply call the RTI_ISR(); from main(); as a
simple
> subroutine.
>
> This makes me think there is nothing wrong with the coding and setup
of
> the IC2 and IC3 interrupts, however, When the RTI is operating as a
RTI,
> the IC2 and IC3 interrupts are simply ignored or not even detected, so
> maybe my code is missing something.
>
> Probably a bit hard to understand as my explanation of the situation
is
> probably not the best..sorry, however,
>
> Is there some trick to getting an interrupt to interrupt another
interrupt
> ?
> ie: An IC interrupt to interrupt an RTI
>
> Any feedback on this subject would be greatly appreciated.
> Thankyou




Reply by Tony Papadimitriou October 23, 20042004-10-23
----- Original Message -----
From: "Garry Sharpe" <>
To: < > Is there some trick to getting an interrupt to interrupt another interrupt
?
> ie: An IC interrupt to interrupt an RTI

First, if you want to simply execute other ISRs that trigger while an ISR is
executing make sure you don't clear the other pending interrupts' flags when
clearing the current interrupt's flag. This can happen if you use the wrong
read-modify-write instructions to clear flags that share a register (e.g.,
IC and/or OC flags).

Second, if you want to actually interrupt another ISR while it is executing,
you must enable interrupts (CLI) from within that first ISR. But, you must
set a variable flag before enabling interrupts and have code to avoid
recursion (in which case you simply exit). Also, have enough stack
available for all ISRs should they trigger together.



Reply by Mark Schultz October 23, 20042004-10-23

--- In , Garry Sharpe <garry_sharpe@y...>
wrote:
> I am a student that is having trouble getting Input Capture
> interrupts (IC2 & IC3) to interrupt an RTI.

...

> Probably a bit hard to understand as my explanation of the
> situation is probably not the best..sorry

Actually, the background information you have provided is pretty
good. A concise, yet complete discussion of your application and
the problem.

It sounds like you're doing everything correctly. The only clue I
have is that you stated that you could call RTI_ISR() from main()
successfully. Is RTI_ISR() properly declared as a interrupt-type
function? I don't recall the proper Imagecraft C syntax for doing
this, but it would be the same syntax that you are (successfully)
using to declare your timer IC functions as ISRs. I would not think
that it would be possible to successfully call a ISR function
directly, unless the compiler is smart enough to generate the
appropriate stack-frame initialization ('interrupt simulation') code
prior to the call. A properly-generated interrupt function will end
with a 'RTI' instruction, which initiates a distinctly different
sequence of events than the 'RTS' instruction that would end
a 'normal' function.

Are you clearing TFLG2.RTIF in RTI_ISR() ? If not, this could be
the cause of your problem. Make sure that you write the value 0x40
to TFLG2 (to clear RTIF) somewhere in RTI_ISR() prior to exit. This
same advice applies to your input capture ISRs; make sure you
perform the appropriate interrupt flag clearing sequence (writing
a '1' to the respective TFLG1.ICxF bit) in each of these routines.

Try adding some test code to RTI_ISR() - assert a unused output port
pin (high) on entry to RTI_ISR(), and unassert it (low) just before
exit. Check the port with a 'scope and verify that it is pulsing
high at your programmed RTI rate. You could also opt to toggle the
port pin, in which case you should see a 50% duty cycle square wave
with a period that is twice your RTI rate.

Bear in mind that when a given ISR is entered, the HC11 WILL NOT
respond to any other interrupt source (other than NMI or RESET)
until you exit the ISR, or explicitly clear the 'I' flag (by
executing the 'CLI' assembly instruction). This is normally not a
problem, esp. if your RTI_ISR() is only executing a short/brief
sequence of instructions and then exiting. Other interrupt sources
are not ignored during this time, they are simply held pending. As
long as you get out of RTI_ISR() before you get two (or more) input
capture events from the same source, you should be in good shape.
The only time you need to execute a CLI within a ISR is if you wish
to give some other interrupt source a higher priority for service.

Since you state that your IC ISRs appear to function correctly and
get serviced when RTI is disabled, I suspect that your IC ISR
functions are declared and written properly.

Hope this helps.

-- Mark


Reply by Garry Sharpe October 23, 20042004-10-23
I am a student that is having trouble getting Input Capture interrupts (IC2 & IC3) to interrupt an RTI.

Basics:

My program, including the RTI, IC2 and IC3 ISR's are written in C whilst all ports, interrupts etc are initiated in assembly. The code is compiled using 'Imagecraft C' and loaded to my E2 chip (in bootstrap) using PCBug11.
(IC2 and IC3 are set for rising and falling edge respectively)

Problem:

My project is designed around a Finite State Model, allowing
void main(void) to simply contain a few initial setup instructions and a while(1); loop, allowing the RTI to take control of the program execution.

Both IC2 and IC3 interrupts are detected and their ISR's executed when I disable the RTI and simply call the RTI_ISR(); from main(); as a simple subroutine.

This makes me think there is nothing wrong with the coding and setup of the IC2 and IC3 interrupts, however, When the RTI is operating as a RTI, the IC2 and IC3 interrupts are simply ignored or not even detected, so maybe my code is missing something.

Probably a bit hard to understand as my explanation of the situation is probably not the best..sorry, however,

Is there some trick to getting an interrupt to interrupt another interrupt ?
ie: An IC interrupt to interrupt an RTI

Any feedback on this subject would be greatly appreciated.
Thankyou

---------------------------------
Find local movie times and trailers on Yahoo! Movies.