ATmega 16 microcontroller interrupt system related registers (VIII)

Publisher:fnfeecjknqucLatest update time:2016-10-22 Source: eefocusKeywords:ATmega  MCU  register Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Reset and interrupt vectors

Vector number Program address Interrupt source Interrupt definition1
    0x000 RESET External pin level trigger, power-on, power-down detection, watchdog, and JTAG AVR reset2
    0x002 INT0 External interrupt request 0 interrupt3
    0x004 INT1 External interrupt request 1 interrupt4
    0x006 TIMER2 COMP Timer/Counter 2 compare match interrupt5 0x008
    TIMER2 OVF Timer/Counter 2 overflow interrupt6
    0x00A TIMER1 CAPT Timer/Counter 1 Event Capture Interrupt7
    0x00C TIMER1 COMPA Timer/Counter 1 Compare Match A Interrupt8
    0x00E TIMER1 COMPB Timer/Counter 1 Compare Match B Interrupt9
    0x010 TIMER1 OVF Timer/Counter 1 Overflow Interrupt10
   0x012 TIMER0 OVF Timer/Counter 0 Overflow Interrupt11
   0x014 SPI_STC SPI serial transfer end
   interrupt12 0x016 USART_RXC USART receive end interrupt
   13 0x018 USART_UDRE USART data register empty
   14 0x01A USART_TXC USART transmit end interrupt
   15 0x01C ADC ADC conversion end interrupt
   16 0x01E EE_RDY EEPROM ready interrupt
   17 0x020 ANA_COMP Analog comparator interrupt
   18 0x022 TWI Two-wire serial interface interrupt
   19 0x024 INT2 External interrupt request 2 interrupt
   20 0x026 TIMER0_COMP Timer/Counter 0 compare match interrupt
   21 $028 SPM_RDY Save program memory content ready

Determination of reset and interrupt vector locations
BOOTRST IVSEL Reset Address Interrupt Vector Starting Address
       1 0 0x0000 0x0002
       1 1 0x0000 Boot Area Reset Address + 0x0002
       0 0 Boot Reset Address 0x0002
       0 1 Boot Reset Address Boot Area Reset Address + 0x0002

1.MCUCR——MCU Control Register

            SM2 SE SM1 SM0 ISC11 ISC10 ISC01 ISC00

Bit 3, 2 - ISC11, ISC10: Interrupt trigger mode control 1 Bit 1 and bit 0
External interrupt 1 is triggered by pin INT1 if the I flag bit and the corresponding interrupt mask bit of the SREG register are set. The MCU first samples the level on the INT1 pin before detecting the edge. If the edge trigger mode or level change trigger mode is selected, a pulse with a duration greater than one clock cycle will trigger an interrupt, and a pulse that is too short cannot guarantee an interrupt. If the low level trigger mode is selected, the low level must be maintained until the current instruction is executed.

ISC11 ISC10 Description
   0 0 An interrupt request is generated when INT1 is at a low level
   0 1 Any logic level change on the INT1 pin will trigger an interrupt
   1 0 The falling edge of INT1 generates an asynchronous interrupt request
   1 1 The rising edge of INT1 generates an asynchronous interrupt request

Bits 1, 0–ISC01, ISC00: Interrupt 0 trigger mode control Bits 1 and 0
External interrupt 0 is triggered by pin INT0 if the I flag bit and the corresponding interrupt mask bit of the SREG register are set. The MCU first samples the level on the INT0 pin before detecting the edge. If the edge trigger mode or level change trigger mode is selected, a pulse lasting longer than one clock cycle will trigger an interrupt, and a pulse that is too short cannot guarantee an interrupt. If the low level trigger mode is selected, the low level must be maintained until the current instruction is executed.

ISC01 ISC00 Description
    0 0 An interrupt request is generated when INT0 is at a low level
    0 1 Any logic level change on the INT0 pin will trigger an interrupt
    1 0 The falling edge of INT0 generates an asynchronous interrupt request
    1 1 The rising edge of INT0 generates an asynchronous interrupt request

2.MCUCSR——MCU Control and Status Register

            JTD ISC2 – JTRF WDRF BORF EXTRF PORF

Bit 6 - ISC2: Interrupt 2 trigger mode control
Asynchronous external interrupt 2 is activated by external pin INT2 if the I flag in the SREG register and the corresponding interrupt mask bit in the GICR register are set. If ISC2 is written as 0, the falling edge of INT2 activates the interrupt. If ISC2 is written as 1, the rising edge of INT2 activates the interrupt. The edge triggering mode of INT2 is asynchronous. As long as a pulse with a width greater than the data shown in Table 36 is generated on the INT2 pin, an interrupt will be triggered. If a low-level interrupt is selected, the low level must be maintained until the current instruction is completed
before an interrupt will be generated. And as long as the pin is pulled low, an interrupt request will be triggered. Interrupts may occur when changing ISC2. Therefore, it is recommended to clear the corresponding interrupt enable bit INT2 in the GICR register first, and then change ISC2. Finally, don't forget to clear the corresponding interrupt flag bit INTF2 in the GIFR register by writing '1' to it before re-enabling interrupts.

3.GICR——General Interrupt Control Register

          INT1 INT0 INT2 – – – IVSEL IVCE

Bit 7 - INT1: Enable external interrupt request 1
When INT1 is '1' and the I flag of the status register SREG is set, the corresponding external pin interrupt is enabled. The interrupt sensitivity level control 1 bit 1/0 (ISC11 and ISC10) of the MCU general control register - MCUCR determines whether the interrupt is triggered by the rising edge, falling edge, or INT1 level. Once enabled, even if the INT1 pin is configured as an output, as long as the pin level changes accordingly, an interrupt will be generated.
Bit 6 - INT0: Enable external interrupt request 0
When INT0 is '1' and the I flag of the status register SREG is set, the corresponding external pin interrupt is enabled. The interrupt sensitivity level control 0 bit 1/0 (ISC01 and ISC00) of the MCU general control register - MCUCR determines whether the interrupt is triggered by the rising edge, falling edge, or INT0 level. Once enabled, even if the INT0 pin is configured as an output, as long as the pin level changes accordingly, an interrupt will be generated.

Bit 5 - INT2: Enable external interrupt request 2
When INT2 is '1' and the I flag of the status register SREG is set, the corresponding external pin interrupt is enabled. The interrupt sensitivity level control 2 bits 1/0 (ISC2 and ISC2) of the MCU general control register - MCUCR determine whether the interrupt is triggered by the rising edge, falling edge, or INT2 level. As long as it is enabled, even if the INT2 pin is configured as an output, as long as the pin level changes accordingly, an interrupt will be generated.

4.GIFR——General interrupt flag register

              INTF1 INTF0 INTF2 – – – – –

Bit 7 - INTF1: External interrupt flag 1
When the level of the INT1 pin changes, an interrupt request is triggered and the corresponding interrupt flag INTF1 is set. If bit I of SREG and the corresponding interrupt enable bit INT1 of the GICR register are "1", the MCU jumps to the corresponding interrupt vector. The flag is automatically cleared after entering the interrupt service routine. In addition, the flag bit can also be cleared by writing "1".
Bit 6 - INTF0: External interrupt flag 0
When the level of the INT0 pin changes, an interrupt request is triggered and the corresponding interrupt flag INTF0 is set. If bit I of SREG and the corresponding interrupt enable bit INT0 of the GICR register are "1", the MCU jumps to the corresponding interrupt vector. The flag is automatically cleared after entering the interrupt service routine. In addition, the flag bit can also be cleared by writing "1".
Bit 5 - INTF2: External interrupt flag 2
When the level of the INT2 pin changes, an interrupt request is triggered and the corresponding interrupt flag INTF2 is set. If bit I of SREG and the corresponding interrupt enable bit INT2 of the GICR register are "1", the MCU jumps to the corresponding interrupt vector. This flag is automatically cleared after entering the interrupt service routine. In addition, the flag bit can also be cleared by writing "1". Note that when the INT2 interrupt is disabled and entering certain sleep modes, the input buffer of this pin will be disabled. This will cause a logic change in the INTF2 flag setting signal.

Keywords:ATmega  MCU  register Reference address:ATmega 16 microcontroller interrupt system related registers (VIII)

Previous article:ATmega 16 MCU SPI related registers (Part 9)
Next article:ATmega 16 MCU WDT timer related registers (Part 7)

Recommended ReadingLatest update time:2024-11-16 14:41

MCS-51 series microcontroller bit control transfer instructions (5)
Boolean processing is an important feature of the MCS-51 series of microcontrollers, which is set up for practical application needs. Boolean variables are also switch variables, which are operated in bits. In terms of physical structure, the MCS-51 microcontroller has a Boolean processor that uses the carry flag as
[Microcontroller]
Several common methods for programming microcontrollers
Recently, I saw a friend asking a relatively basic question, probably asking: What are the common methods for programming microcontrollers? Let’s talk about the three common methods of burning programs: ISP, IAP and ICP, as well as their differences. ISP ISP: In System Programing, in system programming. ISP mea
[Microcontroller]
Several common methods for programming microcontrollers
Several concepts involved in single chip microcomputer development
1. What are "internal pull-up" and "internal pull-down" in DSP? When introducing pins in DSP, PU and PD are marked as "internal pull-up" and "internal pull-down", which means that a pull-up resistor connected to the power supply or a pull-down resistor connected to the ground has been configured internally. In this wa
[Microcontroller]
Xianyang power grid load reaches 2.16 million kilowatts, a new high
On November 30, the power grid load in Xianyang area hit a new high since the beginning of winter at 2,161,080 kilowatts, an increase of 12.34% over the same period last year, and the power grid operation pressure was relatively high. It is predicted that during the peak winter period in 2019, the maximum load
[New Energy]
LED Intelligent Lighting System Based on STC Microcontroller
1 Introduction LED is called the fourth generation of lighting source or green light source. The light emitting device of LED is a cold light source, which has the characteristics of energy saving, environmental protection, long life and small size. The light efficiency of incandescent lamp and halo
[Industrial Control]
LED Intelligent Lighting System Based on STC Microcontroller
Application of Serial Memory AT45DB161B in Vehicle Driving Recorder
1 Overview The main data of the driving recorder include accident suspicion data and driving status data. Among them, the accident suspicion data is the vehicle speed and vehicle braking status signal corresponding to the real time of 20 seconds before the vehicle stops, which is recorded and stored by the
[Automotive Electronics]
Application of Serial Memory AT45DB161B in Vehicle Driving Recorder
MCU Advanced---HLK-W801 Hardware Development Welding Circuit
This is my first time to hand solder patches, and I am just getting started. I was lucky enough to succeed, so I would like to share some of my insignificant experience with you. Welding tool preparation After more than a week of waiting, the things I bought were basically in place. To solder MCU, especially QFN pac
[Microcontroller]
MCU Advanced---HLK-W801 Hardware Development Welding Circuit
A universal system for 80C198 microcontroller measurement and control
The basic components of various measurement and control systems and intelligent instruments and meters include: sensors, computer systems, and actuators. Nowadays, sensors and actuators are becoming more and more versatile. When designing automatic measurement and control systems or intelligent instruments, there are s
[Test Measurement]
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号