PIC microcontroller interrupt module introduction:
PIC 16F87X series microcontrollers can receive up to 14 interrupt sources. The interrupt controller register INTCON marks the request of each interrupt source, sets the mask bit for each interrupt, and sets the global mask bit for all interrupts.
The interrupts of the PIC16F87X series include: TMR0 overflow interrupt (TOIF), external interrupt (INTF), port B change interrupt (RBIF), parallel slave port interrupt (PSPIF), A/D conversion interrupt, USART asynchronous receive interrupt (RCIF) and asynchronous transmit interrupt (TXIF), synchronous serial port interrupt (SSPIF), CCP1 interrupt (CCPIIF), TMR2 interrupt (TMR2IF), TMR1 interrupt, CCP1 interrupt (CCP2), E2PROM write interrupt (EEIF), and bus collision interrupt (BCLIF).
Each interrupt is processed in a query mode, that is, when the CPU port responds to an interrupt, it is necessary to first query the interrupt flag bit to determine which interrupt generated the interrupt request, and then execute the corresponding interrupt service program.
The RB0/INT external interrupt still follows the interrupt principle of the PIC16F87X microcontroller. When an interrupt occurs, an interrupt flag is generated, and the CPU queries and identifies the interrupt. According to this principle, multiple external interrupt sources can be expanded, and the CPU queries the interrupt flag to identify the interrupt after responding to the interrupt.
The external interrupt on the RB0/INT pin is edge-triggered, either rising or falling, which is determined by the INTEDG bit (D6) of the selection register OPTION_REG. When INTEDG = 1, the rising edge is selected; when INTEDG = 0, the falling edge is selected. Once a valid edge is detected on the pin, the INTF bit (D1 of INTCON) is set to 1. This interrupt is enabled or disabled by the interrupt control bit INTE.
To prevent the same interrupt from being executed in an infinite loop, the INTF bit must be cleared to 0 by software in the interrupt service routine before re-enabling the interrupt. If the INTE bit is set to 1 before entering the sleep state, the INT interrupt can wake up the CPU in the sleep state. The state of the GIE bit determines whether the processor jumps to the interrupt vector after being woken up.
When the counter TMR0 of timer TIMER0 overflows (i.e. changes from FFH to 00H), the hardware will automatically set the TGIF position to 1. The interrupt can be controlled by setting the TOIE bit to open or close the interrupt.
When the CPU responds to RB7 and RB4 interrupts, there are two situations: the first is called "short pulse", that is, the pin level returns to the original state during the CPU response to the interrupt, and the CPU will not generate a false interrupt in this case. The second is called "wide pulse", that is, the pin level returns to the original state after the CPU responds to the interrupt, and the process of returning to the original state also generates an interrupt request, which is a false interrupt phenomenon.
Once there is a level change on the D7~D4 pins of port B, the RBIF position is set to 1. This interrupt can be controlled by setting the RBIE bit to control whether the interrupt is open.
The above is the detailed introduction of the PIC microcontroller interrupt module.
Previous article:Introduction to PIC microcontroller reset system module
Next article:Independent key structure in PIC microcontroller
- Popular Resources
- Popular amplifiers
- singlechip-implementation-of-levelcrossing-adc-for-ecg-sampling-2332-0796-1000219
- Introduces the CAN interrupt structure function of C167CR and the application of the standard CAN interrupt structure
- USB Complete The Developer\'s Guide 5ed (USB Development Complete 5th Edition)
- PIC microcontroller controls LED light demonstration code
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- 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
- How to improve the power of voltage doubler rectifier circuit
- Mesh Wi-Fi system enhances smart home applications and makes connectivity easy
- Good tools can make work more efficient: Keysight Technology promotion season is here!
- Introduction to the SIG852 arbitrary waveform generator based on computer software (similar to a virtual oscilloscope)
- Evaluation information is here~~
- It is recommended that the forum organize the posts of the past year
- RFSOC wireless communication development platform
- Littro MicroBox——Ultra-small terminal deep learning recognition module
- Can the power symbol ^ in the matlab result be replaced by pow in C language?
- Design of WiFi-based environmental information IoT cloud platform monitoring system