//★★★★★★★★★Application of interruption (I) ★★★★★★★★★★★\\
//MCU model: PIC16F877A
//Function description: Use interrupt timing to make the RC port light a marquee.
#include
__CONFIG(0xf73A); //Chip configuration word
char i;
//===========================================================================
//Function description: timed interrupt service
//Function name: interrupt TimeInt(void)
void interrupt TimeInt(void)
{
i--;
if(i>6)
{
PORTC=PORTC<<1; //Display shift left one bit (RC0-->RC7-->RC0)
}
else
{
PORTC=PORTC>>1; //Display shift right one bit
if(i<1)
{ i=14;}
}
TMR0 = 0x3d; //timing initial value
T0IF = 0; //clear flag
}
//===========================================================================
//Function description: interrupt setting initialization
//Function name: void IdsInit(void)
void IdsInit(void)
{
OPTION = 0x87; //Division factor
TMR0 = 0x3d; //Timing initial value
T0IE = 1; //Start timing
GIE = 1; //Enable interrupt
}
//Main program
main()
{
TRISC=0x00;
TRISA=0x00;
TRISD=0x00;
PORTC=0x01;
i=14;
IdsInit(); //Interrupt setting initialization
while(1)
{;}
}
Previous article:Digital tube display based on PIC16F877A
Next article:Application of PIC interrupt (Part 2)
Recommended ReadingLatest update time:2024-11-16 12:46
- Popular Resources
- Popular amplifiers
- Principles and Applications of Single Chip Microcomputers 3rd Edition (Zhang Yigang)
- Power Integrated Circuit Technology Theory and Design (Wen Jincai, Chen Keming, Hong Hui, Han Yan)
- Small Compiler Design Practice (Compiled by Su Mengjin)
- STM8 C language programming (1) - basic program and startup code analysis
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
- Common problems and solutions in CCS compilation
- Can TVS be used to extinguish arcs?
- #SpaceX sends 4 civilians into space#When can I travel in space too???
- Please tell me the circuit composed of TL431 directly and optocoupler inside the power supply
- The problem of via aperture and line width
- Use one data line to control full-color LED lights! Single bus LED usage guide
- 【Portable Programmable Meter】Sliding Rheostat Arrived
- Linux environment programming: from application to kernel
- How to connect the reed switch sensor to the microcontroller
- ssh network login