This section describes the interrupt handling of the ATmega8. For more general AVR interrupt handling, see P12 “Reset and Interrupt Handling”.
Notes:
1. When the fuse bit BOOTRST is programmed, the program jumps to the Boot Loader after the MCU is reset.
2. When the IVSEL bit of the GICR register is set, the interrupt vector is transferred to the starting address of the Boot area. At this time, the actual address of each interrupt vector is the sum of the address in the table and the starting address of the Boot area.
Table 19 shows the location of reset and interrupt vectors under different BOOTRST/IVSEL settings. If the program never enables interrupts, the interrupt vector is meaningless. Users can write programs directly here. Similarly, if the reset vector is located in the application area and other interrupt vectors are located in the Boot area, the program can be written directly after the reset vector. The same is true in reverse.
Note:
1. The reset address of the Boot area is listed in Table 82 on P 207. For the fuse bit BOOTRST, “1” means unprogrammed and “0” means programmed.
Typical reset and interrupt settings for ATmega8 are as follows:
When the fuse bit BOOTRST is not programmed, the Boot area is 2K bytes, and the IVSEL bit of the GICR register is set, the typical reset and interrupt settings are as follows:
When the fuse bit BOOTRST is programmed and the Boot area is 2K bytes, the typical reset and interrupt settings are as follows:
When the fuse bit BOOTRST is programmed, the Boot area is 2K bytes, and the IVSEL bit of the GICR register is set, the typical reset and interrupt settings are as follows:
Move interrupts between application and boot areas
The general interrupt control register determines the location of the interrupt vector table.
General Interrupt Control Register - GICR
• Bit 1 – IVSEL: Interrupt vector selection
When IVSEL is "0", the interrupt vector is located at the starting address of the Flash memory; when IVSEL is "1", the interrupt vector is transferred to the starting address of the Boot area. The actual starting address of the Boot area is determined by the fuse bit BOOTSZ. For details, please refer to P 196 "Support for boot loader - self-programming capability that can be read while writing (RWW, Read-While-Write)". In order to prevent unintentional changes to the interrupt vector table, the following process must be followed when modifying IVSEL:
1. Set the interrupt vector modification enable bit IVCE.
2. Write the required data to IVSEL in the next 4 clock cycles, and write "0" to IVCE at the same time.
Interrupts are automatically disabled when the above sequence is executed. In fact, interrupts are disabled when IVCE is set and remain disabled until the next statement after the IVSEL write operation. If there is no IVSEL write operation, interrupts remain disabled for 4 clock cycles after IVCE is set. It should be noted that although interrupts are automatically disabled, the value of bit I of the status register is not affected by this operation.
Note: If the interrupt vector is located in the Boot area and the Boot lock bit BLB02 is programmed, the interrupt is disabled when executing the program in the application area; if the interrupt vector is located in the application area and the Boot lock bit BLB12 is programmed, the interrupt is disabled when executing the program in the Boot area. For details on the Boot lock bit, see P 196 "Supporting Boot Loader - Read-While-Write Self-Programming Capability".
• Bit 0 – IVCE: Interrupt Vector Change Enable IVCE must be set when
changing IVSEL. IVCE is cleared by hardware 4 clock cycles after IVCE or IVSEL is written. As mentioned earlier, setting IVCE will disable interrupts. The code is as follows:
Assembly code examples |
Move_interrupts: ; Enable interrupt vector modification ldi r16, (1< ; Move interrupt vector to boot Flash area ldi r16, (1< ret |
C code example |
void Move_interrupts(void) { /* Enable interrupt vector modification*/ GICR = (1< GICR = (1< |
Previous article:ATmega128 Introduction
Next article:ATmega8 Watchdog Timer
- Popular Resources
- Popular amplifiers
- Learn ARM development(16)
- Learn ARM development(17)
- Learn ARM development(18)
- Embedded system debugging simulation tool
- A small question that has been bothering me recently has finally been solved~~
- Learn ARM development (1)
- Learn ARM development (2)
- Learn ARM development (4)
- Learn ARM development (6)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- From probes to power supplies, Tektronix is leading the way in comprehensive innovation in power electronics testing
- Sn-doped CuO nanostructure-based ethanol gas sensor for real-time drunk driving detection in vehicles
- Design considerations for automotive battery wiring harness
- Do you know all the various motors commonly used in automotive electronics?
- What are the functions of the Internet of Vehicles? What are the uses and benefits of the Internet of Vehicles?
- Power Inverter - A critical safety system for electric vehicles
- Analysis of the information security mechanism of AUTOSAR, the automotive embedded software framework
- Core Experience | Free evaluation and trial of Lingdong MM32 eminiboard, waiting for you!
- The most efficient solution for receiving and sending indefinite length packets on DSP serial port SCI
- (There are still many prizes left in the prize pool!) Mentor downloads the white paper and answers questions for a prize draw
- Be sure to pay attention to safety when driving on the road! Stay away from large vehicles!
- Discussion about MicroPython Engineer's Pocket Toolbox
- Smart gaming dice supporting LED, Bluetooth, wireless charging
- Current status of domestic and foreign automotive radar products
- Prize-winning quiz | TE interconnect solutions help smart cities with intelligent monitoring
- How to set environment variables when installing modelsim and modelsim-altera at the same time
- What the hell is regional chain? Why are the big guys talking about it?