Use of external interrupts of ATMega16 MCU

Publisher:温柔的心情Latest update time:2017-12-15 Source: eefocusKeywords:ATMega16 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

// Crystal: 7.3728M Hz  , Function: Learn the program of external interrupt 0 
      #include  
      #include  

      #define LED_COM    PORTA ^= (1 << PA6)           //  
      void port_init(void) 
      { 
       PORTA = 0x40; 
       DDRA  = 0x40; 
       PORTB = 0x00; 
       DDRB  = 0x00; 
       PORTC = 0x00; //m103 output only 
       DDRC  = 0x00; 
       PORTD = 0x04; 
       DDRD  = 0x00; 
      } 

      #pragma interrupt_handler int0_isr:2 
      void int0_isr(void) 
      { 
        LED_COM; 
      } 

      //call this routine to initialize all peripherals 
      void init_devICes(void) 
      { 
       //stop errant interrupts until set up 
       CLI(); //dISAble all interrupts 
       port_init(); 

       MCUCR = 0x00; 
       GICR  = 0x40; 
       TIMSK = 0x00; //timer interrupt sources 
       SEI(); //re-enable interrupts 
       //all peripherals are now initialized 
      } 

      void main() 
      { 
        init_devices(); 
        while(1) 
        { 
         ; 
        } 

      }


Keywords:ATMega16 Reference address:Use of external interrupts of ATMega16 MCU

Previous article:Basic knowledge of C language for AVR microcontrollers
Next article:ATMEGA16 ADC analog-to-digital conversion example program

Recommended ReadingLatest update time:2024-11-16 12:46

51 MCU Principle and Application--Chip Structure
The internal structure of 51 single-chip microcomputer is as follows: 8-bit CPU  The CPU consists of an arithmetic unit and a controller. The arithmetic unit is mainly responsible for the calculation function of the microcontroller, and the controller is mainly responsible for identifying instructions. Data memory
[Microcontroller]
Single chip microcomputer controlled DC brushless motor drive and interface circuit
  Figure 1 shows the principle block diagram of using 8751 single-chip microcomputer to control DC brushless motor. The P1 port of 8751 is connected with the 7406 inverter to control the commutation of DC brushless motor. The P2 port is used to measure the signals H1, H2, H3 from the position sensor. The P0 port is con
[Microcontroller]
Single chip microcomputer controlled DC brushless motor drive and interface circuit
What is the organizational structure of the 8051 microcontroller memory?
The 8051 memory includes program memory and data memory. From a logical structure point of view, it can be divided into three different spaces: (1) 64KB program memory address space: 0000H~FFFFH, of which 0000H~0FFFH is the on-chip 4KB ROM address space, and 1000H~FFFFH is the external ROM address space;  (2) The
[Microcontroller]
Design of mobile power supply based on IC design and general MCU to realize synchronous Boost
  1. Introduction   With the popularity of smart phones and tablets driven by iPhone and iPad, it is no longer a distant dream for everyone to have a smart phone. Mobile phones and tablets are essential items for people to go out. In addition to the functions of communication, photography and computer, these digital d
[Power Management]
Design of mobile power supply based on IC design and general MCU to realize synchronous Boost
LPC11C14 microcontroller is taken as an example to analyze the solution to the problem that IO cannot output high and low levels.
  Many people always face a problem when using microcontrollers, that is, high and low levels are always output during the use of microcontrollers. Why is this? The editor below will use the LPC11C14 microcontroller as an example to explain to you why the microcontroller IO cannot output high and low levels.   I am
[Microcontroller]
LPC11C14 microcontroller is taken as an example to analyze the solution to the problem that IO cannot output high and low levels.
The role of two capacitors on the microcontroller crystal oscillator
These two capacitors are called the load capacitors of the crystal oscillator, which are connected to the two legs of the crystal oscillator and the capacitance to the ground, respectively. They are usually in the tens of pico hairs. They will affect the resonant frequency and output amplitude of the crystal oscillato
[Microcontroller]
Application of 51 MCU serial port working mode O in expanding parallel output port
  1. System working principle      The following figure is a time controller with adjustable timing from 1 minute to 24 hours. Its printed circuit board is shown in the figure on the right. The controller is based on the AT89C2051 single-chip microcomputer, uses a 12MHz crystal oscillator, and uses the internal timer
[Microcontroller]
Application of 51 MCU serial port working mode O in expanding parallel output port
Design of Doppler blood flow meter system based on 51 single chip microcomputer
Laser Doppler blood flowmeter is an instrument used to measure the blood flow perfusion flow and microcirculation state of tissues and micro-areas in microcirculation research. Using Doppler mobile component to measure blood cell flow is a new method of non-destructive, rapid, continuous and direct measurement of tissu
[Microcontroller]
Design of Doppler blood flow meter system based on 51 single chip microcomputer
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号