To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.pbforthOpen lugnet.robotics.rcx.pbforth in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / pbFORTH / 549
548  |  550
Subject: 
Re: Aborting from ISR
Newsgroups: 
lugnet.robotics.rcx.pbforth
Date: 
Tue, 16 Jul 2002 21:52:06 GMT
Viewed: 
2351 times
  
It works! (after countless crashes and firmwire reloads that is ... :)

By modifying the saved Instruction Pointer to point to a memory area which in
turn contains the address of an "abort word", on the next execution of a word
(either inside a program or the idle loop) the "abort word" will be called
instead.

I've run a couple of tests and it seems to work fine.

Greetings,
Alex

\
\ when RUN is pressed:
\ power off and terminate running prog
\

BASE @
HEX

: AborterWord
  2 4004 SOUND_PLAY
  FFFF 0 DO LOOP
  LCD_CLEAR LCD_REFRESH
  POWER_OFF
  COLD
;

CREATE FakeWord
  ' AborterWord ,
  ' AborterWord ,
  ' AborterWord ,


: run? ( -- runpressed? )
  RCX_BUTTON DUP BUTTON_GET @ 1 AND
;

: AborterISR

  run? 0= IF EXIT THEN


  \ make next NEXT jump to AborterWord
  \ by writing the address of FakeWord
  \ to the saved Forth Instruction Pointer

  FakeWord
  R> R@ SWAP >R        \ get pointer to saved data stack
  CELL+ !              \ saved DS contains ( -- rRSP rFIP rFWP )
;

: StartISR ['] AborterISR TO 'UserISR ;
: StopISR ['] NoOp TO 'UserISR ;

BASE !



Message has 2 Replies:
  RE: Aborting from ISR
 
(...) Alex, I'll have a good look at this and then post an article. I have a funny feeling you're doing it the hard way, but that's because I know the insides of the patient better than you do - I am Dr Frankenforth after all! Oh, and sorry for the (...) (22 years ago, 17-Jul-02, to lugnet.robotics.rcx.pbforth)
  Re: Aborting from ISR
 
Hi, (...) Yup, that does what I want, although I can't remember enough about forth internals to work out why it works. But it does seem to depend on the return stack having a particular structure, so I do wonder - what happens if the interrupt (...) (22 years ago, 20-Jul-02, to lugnet.robotics.rcx.pbforth)

Message is in Reply To:
  Aborting from ISR
 
Hi, Is there any way of ABORTing the current program from the ISR ? I want to attach a routine to 'UserISR and have it ABORT and then execute POWER_OFF when the off/on button is pressed. I would also like to know whether a user program or the idle (...) (22 years ago, 14-Jul-02, to lugnet.robotics.rcx.pbforth)

10 Messages in This Thread:





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
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR