ATmega64 Stack Pointer

Publisher:快乐行者Latest update time:2021-11-12 Source: eefocusKeywords:ATmega64 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

The stack pointer is mainly used to store temporary data, local variables and the return address of interrupts/subroutines. The stack pointer always points to the top of the stack. Note that the AVR stack grows downward, that is, when new data is pushed onto the stack, the value of the stack pointer will decrease. When reading the program counter from the stack after an interrupt/subroutine, the unused bit (bit 15) should be masked.


The stack pointer points to the data SRAM stack area. The subroutine stack and interrupt stack are gathered here. The stack space must be defined before calling a subroutine and enabling interrupts, and the stack pointer must point to an address space higher than 0x60. When data is pushed into the stack using the PUSH instruction, the pointer is reduced by one; and when the subroutine or interrupt return address is pushed into the stack, the pointer is reduced by two. When data is popped out of the stack using the POP instruction, the stack pointer is increased by one; and when returning from a subroutine or interrupt using the RET or RETI instruction, the stack pointer is increased by two.


The stack pointer of AVR is implemented by two 8-bit registers in I/O space. The actual number of bits used depends on the specific device. Please note that the data area of ​​some AVR devices is too small, and SPL is sufficient. In this case, the SPH register will not be given.

ATmega64 Stack Pointer


Keywords:ATmega64 Reference address:ATmega64 Stack Pointer

Previous article:ATmega64 instruction execution timing
Next article:ATmega64 Status Register

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号