Stack Pointer - documentation conflict?
2006-04-05 by Don AE5K
As a longtime user of micros (since the Intel 4004), I know about the necessity of initializing the stack pointer in those devices which have it. However, some of the most recent Atmel datasheets (for example doc2586.pdf, 2586F dated 4/06 on the tiny 25/45/85) lead me to believe that Atmel has gone the way of initializing the stack pointer to the top of SRAM at reset/powerup time. In this doc (2586F), paragraph 5.6.1 shows the "Initial Value" to be "RAMEND". This is great if true, BUT in the paragraph above it (par. 5.6) it says "This Stack space in the data SRAM must be defined by the program before any subroutine calls are executed or interrupts are enabled. The Stack Pointer must be set to point above 0x60." Also an answer to FAQ on the Atmel website that I read says "For all AVR devices with SRAM the stack pointer must be set to point at the last address in SRAM." [I should note that this is not exactly true -- it can be set anywhere in SRAM, just as long as there is enough room in SRAM addresses below it to accommodate anything pushed on the stack!] So the question is "Which is correct?" Is the stack pointer in these newer devices initialized as shown so that the programmer does not need to do the initialization? Regards, Don -- I Haven't Lost My Mind - It's Backed Up On Disk Somewhere