51 MCU interrupt function

Publisher:JoyfulMelodyLatest update time:2016-01-13 Source: eefocus Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
Interrupts are implemented using the interrupt keyword and terminal numbers 0-4:
Return value Function name  interrupt n
n corresponds to the number of the interrupt source. The interrupt number tells the interrupter the entry address of the interrupt program, which corresponds to the enable bit in the IE register, that is, bit 0 in the IE register corresponds to external interrupt 0. The
interrupt sources and terminal numbers of the 8051 microcontroller are as follows:
 
Interrupt number Interrupt Sources Entry address
0 External interrupt 0 0003H
1 Timer/Counter 0 Overflow 000BH
2 External interrupt 1 0013H
3 Timer/Counter 1 Overflow 001BH
4 Serial port interrupt 0023H
 
In the 51 series of single-chip microcomputers, some single-chip microcomputers have up to 32 interrupt sources, so the terminal numbers are 0-31.
When a specific task is being executed, there may be more urgent things that need to be handled by the CPU, which involves interrupt priority. High-priority interrupts can interrupt low-priority interrupt programs that are being processed, so it is best to assign different register groups to each priority program. In C51, you can use using to specify the register group. The variable after using is a constant integer from 0 to 3, which represents the 4 register groups in the 51 single-chip microcomputer. The complete syntax of the interrupt function is as follows:
 return value  function name ([parameter]) [mode] [reentry] interrupt n [usingn]
unsigned int interruptcnt;
unsigned char second;
void timer0 (void) interrupt 1 using 2
if (++interruptcnt==4000)   // count to 4000
second++;         // another counter
interruptcnt=0;   // counter clear
Reference address:51 MCU interrupt function

Previous article:C language program based on 51 single chip infrared encoding and decoding
Next article:Design and simulation of electronic clock

Latest Microcontroller Articles
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号