ATMega16 MCU external interrupt program sharing

Publisher:幸福如愿Latest update time:2020-02-02 Source: eefocusKeywords:ATMega16 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

//Crystal:7.3728MHz, Function: Learn the program of external interrupt 0

#include

#include

#defineLED_COMPORTA^=(1《voidport_init(void)

{

PORT=0x40;

DDRA=0x40;

PORTB=0x00;

DDRB=0x00;

PORTC=0x00;//m103outputonly

DDRC=0x00;

PORTD=0x04;

DDRD=0x00;

ATMega16 MCU external interrupt program sharing

}

#pragmainterrupt_handlerint0_isr:2

voidint0_isr(void)

{

LED_COM;

}

//callthisroutinetoiniTIalizeallperipherals

voidinit_devICes(void)

{

//stoperranTInterruptsunTIlsetup

CLI();//dISAbleallinterrupts

port_init();

MCUCR=0x00;

GICR=0x40;

TIMSK=0x00;//timerinterruptsources

SEI();//re-enableinterrupts

//allperipheralsarenowinitialized

}

voidmain()

{

init_devices();

while(1)

{

;

}

}


Keywords:ATMega16 Reference address:ATMega16 MCU external interrupt program sharing

Previous article:Control design of UAV power management system based on ATemga161 microcontroller
Next article:How to make an ISP download cable for AVR microcontroller

Recommended ReadingLatest update time:2024-11-16 13:34

Freescale MCU clock initialization and configuration
The system clock can select internal or external clock, the clock frequency can be multiplied, the bus clock is 1/2 of the system clock, the timer clock can select the clock source, the clock source can select the bus clock or external clock, etc. (the bus clock is selected in my program), and it can be divided. If
[Microcontroller]
51 single chip simple electronic scale program
This is my single-chip microcomputer design, which is mainly made of pressure sensor, HX711 module and 51 single-chip microcomputer. The attachment contains the schematic diagram and source code of the electronic scale. This simple electronic scale has three modes: Mode 1: ordinary object measurement; Mode 2: pricing
[Microcontroller]
51 single chip simple electronic scale program
Application of COP8CDR9 microcontroller in multi-channel data acquisition
Front-end data acquisition can obtain effective information of the controlled object and production process in time, which is particularly important in some occasions with high real-time requirements. In the industrial production process, in order to clearly reflect the detailed information of the production process,
[Microcontroller]
Application of COP8CDR9 microcontroller in multi-channel data acquisition
Principle of refrigerator protection and energy-saving device based on 89C2051 single-chip microcomputer
This refrigerator protection energy saver has the functions of low protection, overvoltage power control, etc. After trial, it is stable and reliable. This controller can also be used for other home appliances control with a slight modification. Figure 1 is the electrical schematic of the controller. The vo
[Microcontroller]
Principle of refrigerator protection and energy-saving device based on 89C2051 single-chip microcomputer
(IV) Dynamic memory allocation and task scheduling ideas of single-chip microcomputer system
1. Memory allocation: 1.1 Apply for a memory size definition: #define MEM_0_SIZE (8) //8 bytes #define MEM_1_SIZE (16) //16 bytes #define MEM_2_SIZE (32) #define MEM_3_SIZE (64) #define MEM_4_SIZE (128) #define MEM_5_SIZE (256) 1.2 Set the maximum number of memory blocks that can be applied for by SIZE: #define
[Microcontroller]
Design of digital control constant current source circuit based on single chip microcomputer
  0 Introduction   A constant current source is a power source that can provide a constant current to a load, also known as a steady current source or current source. At present, the application of CNC constant current sources is becoming more and more widespread with the development of electronic technology. Consta
[Power Management]
Design of digital control constant current source circuit based on single chip microcomputer
89C52 single chip microcomputer key control
This is a program that uses buttons to adjust the value of the number displayed on the seven-segment display. Pressing one button adds 1, and pressing another button subtracts 1.     program:   #include reg52.h #include INTRINS.H     sbit P2_2=P2^2 ; sbit P2_3=P2^3 ; sbit P3_3=P3^3; sbit P3_4=P3^4;
[Microcontroller]
Design of AT89S51 microcontroller to expand external interrupt source system
AT89S51 provides users with two external interrupt request input terminals INT0 (inverse) and INT1 (inverse). In actual application systems, the two external interrupt request sources are often not enough, and the external interrupt source needs to be expanded. The following introduces a method to expand external inte
[Microcontroller]
Design of AT89S51 microcontroller to expand external interrupt source system
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号