This is a group for folks designing and programming embedded systems using the Rabbit Semiconductor C-programmable microcontroller. Rabbit Semi is a spin-off from Z-World who makes a variety of embedded modules and tools. This group is not affiliated with either Rabbit or Z-World, but is a user forum for sharing ideas, asking questions,
flaunting knowledge, and other typical user group stuff. The Rabbit is a powerful uC, supported by a full-featured C-compiler.
Interrupt Question - kb1ckt - Aug 26 9:40:47 2009
When an interrupt occurs, I presume that the jump-back address is pushed to the stack,
right? Is anything else pushed? I want to write a bit of bad code: When I hit a
particular ISR, I want to jump someplace else, never to return to the original jump-from
location. A goto statement, if nothing else. Basically, I don't have enough time in the
original function to run some sort of monitor to prevent infinite loops, so I need a
time-out timer to jump out of a bit of code.
Shawn
------------------------------------
______________________________
controlSUITE software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )
Re: Interrupt Question - robertbrichter - Aug 26 14:18:28 2009
--- In r...@yahoogroups.com, "kb1ckt"
wrote:
>
> When an interrupt occurs, I presume that the jump-back address is pushed to the stack,
right? Is anything else pushed? I want to write a bit of bad code: When I hit a
particular ISR, I want to jump someplace else, never to return to the original jump-from
location. A goto statement, if nothing else. Basically, I don't have enough time in the
original function to run some sort of monitor to prevent infinite loops, so I need a
time-out timer to jump out of a bit of code.
>
> Shawn
>
An IRQ differs from a call only in that IP is also adjusted, so you need to use an IPRES.
Are you using an IRQ as a watch-dog that is enabled on function entry and disabled on
function exit. You might try this:
char SetjmpReturn[4];
#asm
ld hl, _ReturnFromSetjmp
ld (SetjmpReturn), hl
ld hl, 0
add hl, sp
ld (SetmpReturn+2), hl
ld hl, 0
_ReturnFromSetjmp:
... Code here that knows an error occurred if it gets something other than zero
In the IRQ that breaks out of a stalled sub, it appears you don't care to preserve
registers
ioi ld ... Shutdown this IRQ
ld hl, (SetjmpReturn+2)
ld sp, hl
ld iy, (SetjmpReturn)
ld hl, ErrorCode
ipres
jp (iy)
------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )RE: Interrupt Question - John McCord - Aug 26 15:02:21 2009
Why not simply set a flag in your interrupt routine. The flag is then
checked frequently and you jump wherever when the flag is set. That way you
can keep your code clean.
-John
_____
From: r...@yahoogroups.com [mailto:r...@yahoogroups.com] On
Behalf Of kb1ckt
Sent: Wednesday, August 26, 2009 9:39 AM
To: r...@yahoogroups.com
Subject: [rabbit-semi] Interrupt Question
When an interrupt occurs, I presume that the jump-back address is pushed to
the stack, right? Is anything else pushed? I want to write a bit of bad
code: When I hit a particular ISR, I want to jump someplace else, never to
return to the original jump-from location. A goto statement, if nothing
else. Basically, I don't have enough time in the original function to run
some sort of monitor to prevent infinite loops, so I need a time-out timer
to jump out of a bit of code.
Shawn
______________________________
controlSUITE software. Comprehensive. Intuitive. Optimized.
Real-world software for real-time control. Details Here!

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )Re: Interrupt Question - kb1ckt - Aug 26 15:20:56 2009
I thought about that, but right now, the loop is pretty simple: I increment register d,
then check to see if PEDR bit 1 changed state to the desired state. If not, loop back.
If it changed state, load b into a and then push a into a memory location. Goto next
statement. Right now, with nothing else running, I get about 5 loops inbetween state
changes. RCM3750 running at 22.1MHz.
I think I'm going to set up a FIFO, and just set it so as to sample the port pin. I only
need to sample about every 1-2us, for about 500us.
I tried using the input capture module, capture time on every state change; but found that
it took upwards of 7-8us just to jump to the isr, so that was a no-go. The pulses I'm
looking at around 5us wide, or 10us wide, and there's several in a row to be captured.
Plus, I just realized that the number of transitions is not fixed--I thought I'd always
have x transitions, but it can vary. So, a FIFO seems to make the most sense; I just have
to figure out how to cleanly write the code for 500 samples, at up to 1us per sample. I
wonder if I can do a for loop in a precompiler command in assembly...
Shawn
PS: Code looks like this:
ld d,0
FirstRisingEdge::
ioi ld a,(PEDR)
bit 1,a
jp z,@PC-6
FirstFallingEdge::
inc d
ioi ld a,(PEDR)
bit 1,a
jp nz,@PC-7
ld a,d
ld (RECEIVE_ARRAY),a
SecondRisingEdge::
inc d
ioi ld a,(PEDR)
bit 1,a
jp z,@PC-7
ld a,d
ld (RECEIVE_ARRAY+1),a
SecondFallingEdge::
inc d
ioi ld a,(PEDR)
bit 1,a
jp nz,@PC-7
ld a,d
ld (RECEIVE_ARRAY+2),a
and repeat. Not part of an interupt but rather as inline code, all interupts (and
watchdog) disabled. [Well, I macro'd this code above, but you get the idea.] d wraps
around two or three times currently, but that's ok, as I can detect that easily enough
later on. Right now, d increments up either 5 or 12 counts, depending upon the width of
the pulse I recieve.
--- In r...@yahoogroups.com, "John McCord"
wrote:
>
> Why not simply set a flag in your interrupt routine. The flag is then
> checked frequently and you jump wherever when the flag is set. That way you
> can keep your code clean.
> -John
>
------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )Re: Interrupt Question - robertbrichter - Aug 26 15:42:31 2009
Re: Interrupt Question - kb1ckt - Aug 26 17:57:58 2009
Got past it with the FIFO idea; can sample at nearly 1MS/s. Good enough for now.
Thanks all.
Shawn
------------------------------------

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )
Re: Re: Interrupt Question - Tom Collins - Aug 27 12:31:17 2009
On Aug 26, 2009, at 12:20 PM, kb1ckt wrote:
> FirstRisingEdge::
> ioi ld a,(PEDR)
> bit 1,a
> jp z,@PC-6
Try this out -- I know that it works on the 4000 and later, and it
probably works on the 3000 as well. JR is 2 fewer clocks that JP,
and using IOI with the BIT opcode shaves off another 2 clocks over
using the A register to hold the value read.
ld hl, PEDR
.loop:
ioi bit 1, (hl)
jr z, .loop
-Tom

(You need to be a member of rabbit-semi -- send a blank email to rabbit-semi-subscribe@yahoogroups.com )