Subject:
|
Re: librcx & interrupt handler
|
Newsgroups:
|
lugnet.robotics.rcx
|
Date:
|
Tue, 27 Aug 2002 17:59:48 GMT
|
Viewed:
|
2278 times
|
| |
![Post a public reply to this message](/news/icon-reply.gif) | |
Cédric Meuter <Cedric.Meuter@ulb.ac.be> wrote:
> Hi everyone,
>
> I am trying to use librcx <http://graphics.stanford.edu/~kekoa/rcx/tools.html>
> to write light (in code size) programs for RCX, and up till now it works
> fine, but i'd like to begin using interrupts. I'd like to set my own handler
> for the interrupts. For example, an interrupt handler that would set a
> global variable each time a touch sensor is pressed...
>
> How can I do that kind of thing? i suppose i have to use the ROM interrupt
> vectors defined at the very end of "rom.h"... what interrupt vector do I
> have to use for which input (buttons, sensor, IR)... what exactly must the
> handlers do?
>
> any help greatly appriciated...
How much info do you want about all this? Specific questions are good if
this does not get at what you are wondering about.
The interrupt vectors at the end of rom.h are the ones to play with. The
true interrupt vectors are in ROM, as are a set of interrupt handlers, but
these dispatch to the addresses at the end of rom.h. To use the routines,
you can just write something like:
VECTOR_A_D = pointer_to_a_void_function_with_no_parameters;
But there are some complications.
First, there is not always a direct mapping between interrupt vectors and
the inputs. Often you need to do some processing, such as A/D conversion
for the sensors, or timed sampling and debouncing for reading the buttons.
Second, you'll have to be careful about register conventions. The ROM uses
one set of conventions, and, at least when I was doing this before, GCC
used another set of conventions. Looking over code I wrote, it seems that
when I wrote handlers in C, I had to use a wrapper to save r0-r3 because
the routines GCC created assumed the caller had saved these and these
registers were not already saved. On the other hand, when I wrote handlers
in asm, I was able to use r6 without saving it, because the ROM saves this
register, but then I had to save any other registers I used.
Third, if you want to use a combination of routines/handlers in ROM and
your own custom routines, you'll have to be careful not to stomp on things
that the ROM is doing.
So.
You can find a some low-level documentation here:
http://graphics.stanford.edu/~kekoa/rcx/romref.html#Microlevel
(scroll down to "Microcontroller Interface")
Also, it might help to look at the pseudocode for the handlers and other
routines that are in ROM already:
http://graphics.stanford.edu/~kekoa/rcx/#Rom
(scroll down to "Notes on routines")
In any event, I wrote a set of "driver" routines once. You might be
interested in that code, with the caveat that it is incomplete, but you
might find some ideas and answers in that code. That code is here:
http://graphics.stanford.edu/~kekoa/rcx/driver/
Sorry it's not a tarball, and sorry if it's a bit unclear why I did things
the way I did... I can try to answer specific questions about the code, or
other questions you might have if you have them.
-Kekoa
|
|
Message has 1 Reply: ![](/news/x.gif) | | Re: librcx & interrupt handler
|
| Hello, First, thanx for your answer, I'll be looking at the code and link you mentioned, today, it may very well answer the question I have... (...) everyone, (...) (URL) (...) programs for RCX, and up till now it works (...) like to set my own (...) (22 years ago, 28-Aug-02, to lugnet.robotics.rcx)
|
Message is in Reply To:
![](/news/x.gif) | | librcx & interrupt handler
|
| Hi everyone, I am trying to use librcx (URL) to write light (in code size) programs for RCX, and up till now it works fine, but i'd like to begin using interrupts. I'd like to set my own handler for the interrupts. For example, an interrupt handler (...) (22 years ago, 26-Aug-02, to lugnet.robotics.rcx)
|
7 Messages in This Thread: ![librcx & interrupt handler -Cédric Meuter (26-Aug-02 to lugnet.robotics.rcx)](/news/x.gif) ![](/news/46.gif) ![You are here](/news/here.gif) ![](/news/46.gif) ![Re: librcx & interrupt handler -Cédric Meuter (28-Aug-02 to lugnet.robotics.rcx)](/news/x.gif) ![](/news/46.gif) ![Re: librcx & interrupt handler -Kekoa Proudfoot (28-Aug-02 to lugnet.robotics.rcx)](/news/x.gif) ![](/news/46.gif) ![Re: librcx & interrupt handler -Cédric Meuter (29-Aug-02 to lugnet.robotics.rcx)](/news/x.gif) ![](/news/46.gif) ![Re: librcx & interrupt handler -Kekoa Proudfoot (29-Aug-02 to lugnet.robotics.rcx)](/news/x.gif) ![](/news/46.gif) ![Re: librcx & interrupt handler -Cédric Meuter (30-Aug-02 to lugnet.robotics.rcx)](/news/x.gif)
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|