Subject:
|
Re: librcx & interrupt handler
|
Newsgroups:
|
lugnet.robotics.rcx
|
Date:
|
Wed, 28 Aug 2002 05:28:15 GMT
|
Viewed:
|
2386 times
|
| |
![Post a public reply to this message](/news/icon-reply.gif) | |
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...
In lugnet.robotics.rcx, Kekoa
Proudfoot writes:
> 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.
Well, at the moment, I'm looking into writing a very basic set of functions
for IR
messaging. The "send" is already present in librcx, but for the "recieve"
function, instead of
actively waiting for an incoming message (things like "while (1) { if
(message_waiting())
do_something() }"), I'd like to set up a handler that would copy the message
in some buffer I could
check later on in the program... I'm not (not yep hopefuly) familiar with
the RCX (H8/3292)
architecture, but I suppose there must be an interrupt linked to the IR port...
>
> 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
Thanx again, for your answer, and by the way, you might want to know that I
succesfully
compiled c++ program with librcx. Here's what I did:
1. Added a ".tor" section in the
"rcx.lds" script for constructor and destructor (I'm not exactly sure why a
special section is
needed, but I did it anyway)
2. Added the /legOS/lib/c++/libc++.a (thanx to Markus for
writing this) for functions like "__native_new", "__native_delete", etc
And that's it,
basicaly. I check with a few programs and it seem's to work, so far :-).
Cédric Meuter
|
|
Message has 1 Reply: ![](/news/x.gif) | | Re: librcx & interrupt handler
|
| (...) The ROM already supports a buffer size of 1 if that is enough for you. The ROM receives a message asynchronously into that buffer, and you can check it whenever you like and respond accordingly. The code I linked to should help you with buffer (...) (22 years ago, 28-Aug-02, to lugnet.robotics.rcx)
|
Message is in Reply To:
![](/news/x.gif) | | Re: librcx & interrupt handler
|
| (...) 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 (...) (22 years ago, 27-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) ![Re: librcx & interrupt handler -Kekoa Proudfoot (27-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 -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
|
|
|
|