EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

AVR stack problem

Started by Unknown May 5, 2005
I hope this is an okay group to ask this in, if not I apologise. (and
could someone point me to a better location)

I just got my deign up and running using an AVR Mega128. For some odd
reason it looks like my stack is disabled. Within AVRStudio the stack
monitor has all of the stack entries grayed out and each is labeled
"disabled".

How would I fix this?


thanks,
nprophet
www.nprophet.com

n.prophet@gmail.com wrote:
> I hope this is an okay group to ask this in, if not I apologise. (and > could someone point me to a better location) > > I just got my deign up and running using an AVR Mega128. For some odd > reason it looks like my stack is disabled. Within AVRStudio the stack > monitor has all of the stack entries grayed out and each is labeled > "disabled". > > How would I fix this? > > > thanks, > nprophet > www.nprophet.com >
for AVRstudio did you select the divice?
Yes. The correct device appears to be selected.

n.prophet@gmail.com wrote:
> Yes. The correct device appears to be selected. >
I am using avrstudio 3.53 and 4.0x. If you have your code set up correctly you should see the Stackpointer being set. should be one of the 1st instructions.
It looks like everything is set up correctly. The grayed out fields on
in AVRStudio might be that limits are disabled. In any case, when I
step through my code everything seems to work, the stack pointer
changes correctly but on a return from subroutine I head off into the
woods.

I am not using external SRAM and it almost looks like the code is
trying to use it.

Any help would be greatly appreciated.

<n.prophet@gmail.com> skrev i meddelandet 
news:1115321661.012848.204120@z14g2000cwz.googlegroups.com...
> It looks like everything is set up correctly. The grayed out fields on > in AVRStudio might be that limits are disabled. In any case, when I > step through my code everything seems to work, the stack pointer > changes correctly but on a return from subroutine I head off into the > woods. > > I am not using external SRAM and it almost looks like the code is > trying to use it. > > Any help would be greatly appreciated. >
If you use a link file which assumes external RAM the stack might be situated in external RAM. -- Best Regards, Ulf Samuelsson This is intended to be my personal opinion which may, or may bot be shared by my employer Atmel Nordic AB
n.prophet@gmail.com wrote:
> It looks like everything is set up correctly. The grayed out fields on > in AVRStudio might be that limits are disabled. In any case, when I > step through my code everything seems to work, the stack pointer > changes correctly but on a return from subroutine I head off into the > woods. > > I am not using external SRAM and it almost looks like the code is > trying to use it. > > Any help would be greatly appreciated. >
I am using this asm code to set up the stackpointer. ramend is at 0FFF'h for atmega 103 and 128 reset: ; ************* Stack Pointer Setup Code ldi wl,high(ramend-5) ; Stack Pointer Setup out SPH,wl ; Stack Pointer High Byte ldi wl,low(ramend-5) ; Stack Pointer Setup out SPL,wl ; Stack Pointer Low Byte this should work to init the SP
I figured out that my stack pointer is being initializaed outside of my
internal SRAM  space. That should fix it. Thanks.

Hi,
> I just got my deign up and running using an AVR Mega128. For some odd > reason it looks like my stack is disabled. Within AVRStudio the stack
Have a look at: http://ftp.gnu.org/savannah/files/avr-libc/doc/avr-libc-user-manual/FAQ.html It appears that your fuse bits are still in compatibility mode i.e. pretending that you are using an Atmega 103. ...Well, certain odd problems arise out of the situation that the AVR devices as shipped by Atmel often come with a default fuse bit configuration that doesn't match the user's expectations. Here is a list of things to care for: .... . The ATmega128 ships with the fuse enabled that turns this device into ATmega103 compatibility mode. This means that some ports are not fully usable, and in particular that the internal SRAM is located at lower addresses. Since by default, the stack is located at the top of internal SRAM, a program compiled for an ATmega128 running on such a device will immediately crash upon the first function call (or rather, upon the first function return). .... /Roland

The 2024 Embedded Online Conference