Address space planning
Open m16def.inc and you can see the following definition, which corresponds one-to-one with the address space of FlashROM, SRAM, EEPROM, etc. described in the manual.
; ***** DATA MEMORY DECLARATIONS *****************************************
.equ FLASHEND = 0x1fff ; Note: Word address, here is a total of 8K word flash ROM
.equ IOEND = 0x003f ; The address space of IO registers is 0x0000-0x003F, but they are mapped to 0x0020-0x005F
.equ SRAM_START = 0x0060; 0x0060-0x0045F This 1KB address space is the address space used by the internal RAM
.equ SRAM_SIZE = 1024;
.equ RAMEND = 0x045f;
.equ XRAMEND = 0x0000 ; This may be the address space reserved for external RAM - question-001
.equ E2END = 0x01ff; EEPROM has a total of 512B, occupying the address space of 0x0000-0x01FF
.equ EEPROMEND = 0x01ff; This address is sent to the EEPROM control register for use
.equ EEADRBITS = 9 ; 512 cells require 9 address lines to access
#pragma AVRPART MEMORY PROG_FLASH 16384 ; 8K word = 16K byte
#pragma AVRPART MEMORY EEPROM 512
#pragma AVRPART MEMORY INT_SRAM SIZE 1024
#pragma AVRPART MEMORY INT_SRAM START_ADDR 0x60
After the compiler is finished compiling, the usage of FlashROM (.cseg), SRAM (.dseg), and EEPROM (.eseg) will be given:
illustrate:
1. When using the in and out instructions to access IO registers, these two instructions use the address space of 0x0000-0x003F to access IO registers.
2. When using ld and st instructions to access IO registers, you need to use the mapped address space 0x0020-0x005F ([0x0000, 0x003F]+0x0020) to access IO registers.
IO registers such as PORTB and SREG are defined in the m16def.inc file according to the address space of 0x0000-0x003F.
Therefore, when using the ld and st instructions, the register address needs to be added with 0x0020: PORTB + 0x20, SREG + 0x20.
Stack space in RAM
0. The stack (actually refers to the stack) is also part of the RAM, but it can be accessed in FILO form using special instructions push/pop and the stack pointer SP (the address automatically increases or decreases in SP).
In DEBUG mode, we can see that the SP pointer is placed at the end of the RAM, growing downwards from the back.
1. In the reset interrupt service routine, the stack pointer SP is set to 0x045F, which is the last unit of the RAM address space:
RAMEND is defined in m16def.inc as follows (part of the above code):
.equ RAMEND = 0x045f
2. The push instruction saves the data in R20 to the RAM unit pointed to by the SP pointer, that is, pushes it onto the stack:
3. Pop instruction, take out the contents of the RAM unit pointed to by SP pointer and put it into R20, that is, pop the stack:
Previous article:B001-Atmega16-PORTA definition-(ques=1)
Next article:B001 - Atmega16 - Alignment Mode and Endianness
Recommended ReadingLatest update time:2024-11-21 21:09
- Popular Resources
- Popular amplifiers
- Learn C language for AVR microcontrollers easily (with video tutorial) (Yan Yu, Li Jia, Qin Wenhai)
- ATmega16 MCU C language programming classic example (Chen Zhongping)
- IC packaging basics and engineering design examples
- AVR MCU Principles and GCC Programming Practice: System Development of Smart Car
- Naxin Micro and Xinxian jointly launched the NS800RT series of real-time control MCUs
- How to learn embedded systems based on ARM platform
- Summary of jffs2_scan_eraseblock issues
- Application of SPCOMM Control in Serial Communication of Delphi7.0
- Using TComm component to realize serial communication in Delphi environment
- Bar chart code for embedded development practices
- Embedded Development Learning (10)
- Embedded Development Learning (8)
- Embedded Development Learning (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Intel promotes AI with multi-dimensional efforts in technology, application, and ecology
- ChinaJoy Qualcomm Snapdragon Theme Pavilion takes you to experience the new changes in digital entertainment in the 5G era
- Infineon's latest generation IGBT technology platform enables precise control of speed and position
- Two test methods for LED lighting life
- Don't Let Lightning Induced Surges Scare You
- Application of brushless motor controller ML4425/4426
- Easy identification of LED power supply quality
- World's first integrated photovoltaic solar system completed in Israel
- Sliding window mean filter for avr microcontroller AD conversion
- What does call mean in the detailed explanation of ABB robot programming instructions?
- Breaking through the intelligent competition, Changan Automobile opens the "God's perspective"
- The world's first fully digital chassis, looking forward to the debut of the U7 PHEV and EV versions
- Design of automotive LIN communication simulator based on Renesas MCU
- When will solid-state batteries become popular?
- Adding solid-state batteries, CATL wants to continue to be the "King of Ning"
- The agency predicts that my country's public electric vehicle charging piles will reach 3.6 million this year, accounting for nearly 70% of the world
- U.S. senators urge NHTSA to issue new vehicle safety rules
- Giants step up investment, accelerating the application of solid-state batteries
- Guangzhou Auto Show: End-to-end competition accelerates, autonomous driving fully impacts luxury...
- Lotus launches ultra-900V hybrid technology "Luyao" to accelerate the "Win26" plan
- The Hummingbird E203RISCV processor uses custom assembly instructions and NICE bus to read and write control ideas for the coprocessor memory
- [Long-term recruitment] Beijing Haidian - Annual salary starting from 600,000 - Embedded software and hardware engineer
- Performance and application of electric test pencil
- DIY smart car - "RoboMaster", the software framework has been open sourced
- How to answer the final question in an interview
- EEWORLD University Hall - Introduction to Motors
- Announcement of Moderator Chip Coin and Physical Gift Rewards in July 2018
- Tube Amplifiers (4th Edition)
- 【Meet friends by dismantling】KG316T microcomputer time control switch
- Is it feasible to use a digital bridge to measure the resistance of a hygroscopic resistor to indicate humidity?