To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.legosOpen lugnet.robotics.rcx.legos in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / legOS / 53
52  |  54
Subject: 
Re: H8300 Stack and SLEEP
Newsgroups: 
lugnet.robotics.rcx.legos, lugnet.robotics.rcx.pbforth, lugnet.robotics
Date: 
Tue, 16 Mar 1999 02:17:56 GMT
Viewed: 
1830 times
  
Ralph Hempel <rhempel@bmts.com> wrote:
I just figured out this weekend (thanks Kekoa) that the H8/300 stack
pointer (r7) and the power-down function in the RCX have a close
relationship.

The stack pointer MUST be in the on-chip RAM area (0xFD80 to 0xFF7F)
before calling the RCX shutdown_power() function. This is because the
shutdown_power() funtion (I think) deselects the external RAM to put
it into a low-power mode before putting the CPU itself to sleep.

If r7 is pointing outside of the on-chip RAM, then it cannot be
retrieved and the RCX will hang, and in such a nasty way that you
will have to remove the batteries for about 5 minutes - not a few
seconds like normally.

This is especially important for users of legOS and pbFORTH since we
are likely to allocate task stacks or put the stack pointer outside of the
small 512 byte stack area.

After talking with Ralph over the weekend, I suggested a test he might do
to figure out if port 5 bit 2 really does what he suggested it might.  I
don't think he did this test, so I fired up my RCX and hacked it together.

I verified that port 5 bit 2 does indeed appear to put the RAM in low-power
mode.

The tests were simple.  First test: move stack to on-chip RAM, verify that
power_off is broken.  Second test: move stack to on-chip RAM, replicate the
ROM power_off function in asm, remove the code that puts RAM into low power
mode, call modified power_off instead of ROM power_off, verify that new
power_off works.

The problem with having RAM in low-power mode when returning from sleep (if
this is indeed what is going on) is subtle.  The instruction after the
sleep lives in ROM and turns the RAM back on.  At first glance, the RAM
does not seem to be accessed until the rts from power_off, when the return
address is fetched from the stack.  This is not the case.  Sleep ends on
IRQ1; the interrupt handler is called before power to RAM is restored, and
the stack is needed at this time.

-Kekoa



Message has 2 Replies:
  RE: H8300 Stack and SLEEP
 
Kekoa wrote: <<snipped original description of problem>> (...) <<snipped description of tests>> Once again, Kekoa goes the extra mile and proves what many of us are happy to be merely confident about. Someday, I'd like to be reincarnated as a grad (...) (26 years ago, 16-Mar-99, to lugnet.robotics.rcx.legos, lugnet.robotics.rcx.pbforth, lugnet.robotics)
  Re: H8300 Stack and SLEEP
 
Sorry I'm late. I believe this is not an issue with legOS. legOS only calls the ROM powerdown function at the end of its kmain() loop, where the stack pointer should be in the on-chip RAM area anyway. When sleeping in the idle task, legOS directly (...) (26 years ago, 20-Mar-99, to lugnet.robotics.rcx.legos)

Message is in Reply To:
  H8300 Stack and SLEEP
 
Hi All, If this is old news, ignore it... I just figured out this weekend (thanks Kekoa) that the H8/300 stack pointer (r7) and the power-down function in the RCX have a close relationship. The stack pointer MUST be in the on-chip RAM area (0xFD80 (...) (26 years ago, 15-Mar-99, to lugnet.robotics.rcx.legos, lugnet.robotics.rcx.pbforth, lugnet.robotics)

4 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