By modifying the interrupt control register IP, interrupts can be nested and the interrupt priority can be modified. The specific C program is as follows:
#include
#include
#define uint unsigned int
#define uchar unsigned char
void delay(uint z)//延时函数
{
while(z--);
}
void main()
{
// uint i,j;
// i=0xfe;
// j=0x01;
EA=1;
EX0=1;
EX1=1;
PX0=0;
PX1=1;
}
void intt0() interrupt 0
{
uint i=0xfe;
while(1)
{
i=_crol_(i,1);
P2=i;
delay(50000);
}
}
void intt1() interrupt 2
{
uint j=0x01;
while(1)
{
j=_crol_(j,1);
P2=j;
delay(50000);
}
}
#include
#define uint unsigned int
#define uchar unsigned char
void delay(uint z)//延时函数
{
while(z--);
}
void main()
{
// uint i,j;
// i=0xfe;
// j=0x01;
EA=1;
EX0=1;
EX1=1;
PX0=0;
PX1=1;
}
void intt0() interrupt 0
{
uint i=0xfe;
while(1)
{
i=_crol_(i,1);
P2=i;
delay(50000);
}
}
void intt1() interrupt 2
{
uint j=0x01;
while(1)
{
j=_crol_(j,1);
P2=j;
delay(50000);
}
}
The assembly language program is as follows:
ORG 0000H
AJMP MAIN
ORG 0003H
AJMP INTT0
ORG 0013H
AJMP INTT1
ORG 0030H
MAIN:SETB EA
SETB EX0
SETB EX1
CLR PX0
SETB PX1
AJMP $
INTT0:MOV A,#0FEH
LOOP1:MOV P2,A
RR A
ACALL DELAY
AJMP LOOP1
RETI
INTT1:MOV A,#01H
LOOP2:MOV P2,A
RR A
ACALL DELAY
AJMP LOOP2
RETI
DELAY:MOV R6,#255
LP: MOV R7,#100
DJNZ R7,$
DJNZ R6,LP
RET
END
ORG 0000H
AJMP MAIN
ORG 0003H
AJMP INTT0
ORG 0013H
AJMP INTT1
ORG 0030H
MAIN:SETB EA
SETB EX0
SETB EX1
CLR PX0
SETB PX1
AJMP $
INTT0:MOV A,#0FEH
LOOP1:MOV P2,A
RR A
ACALL DELAY
AJMP LOOP1
RETI
INTT1:MOV A,#01H
LOOP2:MOV P2,A
RR A
ACALL DELAY
AJMP LOOP2
RETI
DELAY:MOV R6,#255
LP: MOV R7,#100
DJNZ R7,$
DJNZ R6,LP
RET
END
Previous article:Some summary on interrupt nesting
Next article:A typical error about single chip timer interrupt
- Popular Resources
- Popular amplifiers
Recommended Content
Latest Microcontroller Articles
He Limin Column
Microcontroller and Embedded Systems Bible
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
MoreSelected Circuit Diagrams
MorePopular Articles
- 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
MoreDaily News
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
Guess you like
- Mobile 5G device antenna tuning knowledge
- Last day: Apply for free evaluation, Bear Pi folding development board
- Those who are familiar with solar photovoltaic laminators, please come in!
- How to change the SinA332.0 development board from VGA output to LCD output
- Why is large-screen splicing becoming more and more market-oriented?
- MSP430 MCU matrix keyboard driver LED
- 【Smart Sports Watch】2. Build Development Environment 1
- Low Power Wi-Fi: How Application Attributes Affect Energy Consumption
- USB Type-C interface desktop monitor dedicated solution - single interface solution
- How is this switching transformer wound?