MCU interrupt experiment 2

Publisher:快乐旅行Latest update time:2016-04-19 Source: eefocusKeywords:MCU Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Circuit Diagram:
MCU interrupt experiment 2
code show as below:
#include
#include
 
sbit p1_0 = P1^0; 
sbit p1_1 = P1^1;
 
void delay (void) {
int a = 500;
while(a--) _nop_();
}
 
void LED_01() interrupt 0 using 1 {
delay();
if (INT0 == 0) {
p1_0 = !p1_0;
while (INT0 == 0);
}
 
}
 
void LED_02() interrupt 2 using 1 {
delay ();
if (INT1 == 0) {
p1_1 = !p1_1;
while (INT1 == 0);
}
}
 
void main () {
p1_0 = 0;
p1_1 = 0;
EA = 1;
EX0 = 1;
EX1 = 1;
while(1);
}

Keywords:MCU Reference address:MCU interrupt experiment 2

Previous article:MCU interrupt experiment 3
Next article:MCU interrupt experiment 1

Recommended ReadingLatest update time:2024-11-16 23:36

51 single chip microcomputer realizes 8x8LED light array to dynamically display moving text
I use the Puzhong Technology 51 single-chip microcomputer, other brands are also OK, but you need to change the serial port Without further ado, here is the code.   //test1.h #include"reg51.h" #include"intrins.h" typedef unsigned  char  u8; typedef unsigned  int u16; sbit SRCLK=P3^6; sbit RCLK =P3^5;  sbit
[Microcontroller]
Timing Analysis of Power-on Reset and Reset Delay of 80C51 MCU
The power-on reset (POR) of the 80C51 microcontroller is essentially a power-on delay reset, which means that the microcontroller is locked in the reset state during the power-on delay period. Why is it necessary to add a certain delay time every time the microcontroller is powered on? The analysis is as follows.
[Industrial Control]
Timing Analysis of Power-on Reset and Reset Delay of 80C51 MCU
Do I need to buy a development board for self-study of microcontroller? How do beginners use microcontroller development boards?
It can be said that 99% of the old engineers who are engaged in microcontroller development, or the new microcontroller software engineers, have bought development boards, or have been using development boards to engage in microcontroller development. Some people may question this statement. If you question it, then y
[Microcontroller]
The difference between the two models of single-chip microcomputers: AT89C51 and AT89C52
There are two models of single chip microcomputers. The main difference is the capacity. The at89c51 supports a maximum of 4KB of program, while the at89c52 supports a maximum of 8KB of program. AT89C51 Introduction: AT89C51 is a low-voltage, high-performance CMOS 8-bit microprocessor with 4K bytes of FLASH memory (
[Microcontroller]
Microcontroller beginner's guide (9) Using a universal soldering board to build an experimental circuit
In this article, we will continue the topic of the previous article and explain another way to build your own circuit: using a universal soldering board to build a circuit. Before that, let's first popularize some basic knowledge. Circuit Board First, let's learn about circuit boards. As mentioned earlier, breadboar
[Microcontroller]
Microcontroller beginner's guide (9) Using a universal soldering board to build an experimental circuit
How to set parity check for serial communication of 51 single chip microcomputer
Usually, the format of a frame of serial communication is 8-n-1, that is, 8 bits of data, no parity, and 1 stop bit. Sometimes, in order to improve accuracy, you need to add an "odd" or "even" check bit. For high-level languages, it is very simple to do this. Just change the format command "8-n-1" to "8-P-1" or "8-O-
[Microcontroller]
MCU-based intelligent injection device can realize intelligent iontophoresis therapy
Iontophoresis is a treatment method that allows drugs to penetrate the human body through the skin. Drugs absorbed through the skin are charged mixtures that flow through the skin driven by an electric current. To inject the appropriate dose of drug, the current passing through the skin must be effectively controlle
[Medical Electronics]
MCU-based intelligent injection device can realize intelligent iontophoresis therapy
Microcontrollers that combine Hi-Fi, intelligence and USB multi-channel features – ushering in a new era of digital audio
With the continuous integration of many technological breakthroughs and new streaming services, and the growing prosperity of the smart home and smart speaker markets, consumers' demand for audio is no longer limited to sound quality itself, but more about pursuing high-quality life experience and convenient smart i
[Analog Electronics]
Microcontrollers that combine Hi-Fi, intelligence and USB multi-channel features – ushering in a new era of digital audio
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号