DPRG
DPRG List  



[DPRG] Re: HELP with 68HC11 stack problem

Subject: [DPRG] Re: HELP with 68HC11 stack problem
From: David P. Anderson dpa at io.isem.smu.edu
Date: Wed Jun 20 14:54:36 CDT 2001

Hi DPRG

Clay wrote:

> HELP!   I'm having a problem with a 68HC11 microcontroller board.
> I consider myself a near expert on the 68HC11 but this one has me baffled.
> I'm not even sure of the most basic question.  Is this a software or hardware
>  I've spent about 3 hours tracking down this one and still haven't
> found it.  For reference I'm using a New Micros NMIY-0020 board and
> Imagecraft ICC11 C-compiler.
> 
> My code runs fine when the very first instruction is  LDS #0x00FF
> which loads the stack pointer to the 256 byte RAM internal to the HC11 itself.
> 
> When I cange the code to LDS #0x4000 to initalize the stack pointer
> to external RAM  I have a problem.   On powerup nothing happens
> but then if I hit the reset button it works fine.   I can't figure out why
> it would hang on powerup but work after reset?  Powerup should be
> the same as reset right...  I also really wonder what its doing when
> it appears to hang.
> 
> 
> Anyone ever set the stack to external memory?    Any advantage/disadvantage?
> I think everything should work the same with the stack in external or internal
> memory.  My code has grown and grown and now I'm needing more stack space.

I'm using the ICC11 C-compiler also, and set the stack to external memory at $ddf0.
Here is the first part of the C root file, "crt11.s" 

        .text
__start::                       ; entry point
        lds     #init_sp
        jsr     __HC11Setup     ; define your own HC11 rtn if you want to do
                                ; initialization stuff at the first 64 cycles
                                ; after reset.
; clear BSS
        clra
        ldx     #__bss_start
init_loop:
        cpx     #__bss_end
        beq     init_done
        staa    0,x
        inx
        bra     init_loop


<snip>

The __HC11Setup referenced above is just a stub with an RTS instruction.
The #init_sp is defined in the makefile as options to the linking loader:

ICC11_LINKER_OPTS = -dheap_size:0x1600 -btext:0x8000.0xbfd6:0xc000.0xffd6\
                        -dinit_sp:0xffd0 -m -l6270 -lc -lfp


I've never experience the behavior you are describing.  What mode (single chip,
expanded, factory test, download) does the chip power up in?

regards,
dpa



More information about the DPRG mailing list