Application of PIC interrupt (I)

Publisher:冰雪勇士Latest update time:2016-11-04 Source: eefocusKeywords:PIC Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
//Application of interruption (I)

//★★★★★★★★★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) 
{;}
}

Keywords:PIC Reference address:Application of PIC interrupt (I)

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

Functions of PIC8-bit microcontroller pin symbols
    After reading the introduction to the product performance and corresponding package pins of PIC 8-bit microcontrollers, the author believes that beginners need to understand the meaning of each pin symbol before they can further learn and use it. The author provides relevant explanations for this purpose so that b
[Microcontroller]
51, Comparison of PIC and AVR microcontrollers
1. Traditional 51         I don't think I will say much about the traditional 51. It is suitable for beginners, easy to use, and the price is average (in terms of cost performance).         Disadvantages: easy to decrypt (the traditional 51 says: who let us debut early, everyone is studying me, hey! Cry...) It also h
[Microcontroller]
MCC18 platform code for frequency measurement based on PIC18F45K20
#include #include delays.h #include timers.h   typedef unsigned int  uint; typedef unsigned char uchar; typedef unsigned long ulong;   // 4-bit digital tube position value register definition fly show3, show2, show1, show0;   //8-segment digital tube display code table const char LED_CODE =  {
[Microcontroller]
PIC microcontroller I2C communication (slave mode)
There are many explanations on the Internet about how to implement I2C master mode with microcontrollers, but few about slave mode. I will now talk about how to implement I2C slave mode with PIC microcontrollers using the MSSP module.     For a detailed introduction to the I2C protocol, please refer to "PIC Microcontr
[Microcontroller]
PIC microcontroller I2C communication (slave mode)
PIC microcontroller about PAGE and BANK
Let's analyze why PIC has BANK and PAGE settings from the perspective of PIC's instruction structure. First, let's look at why PIC divides the RAM area into multiple BANKs. Carefully observe the format of PIC assembly language instructions. A complete assembly language instruction statement is usually like this: label
[Microcontroller]
Basic knowledge of PIC microcontroller instruction system
Basic knowledge of PIC microcontroller instruction system: A instruction system refers to a set of all instructions that a single-chip microcomputer can recognize. (The instruction system of the PIC series single-chip microcomputer adopts a reduced instruction set RISC structure system) B The instruction system is
[Microcontroller]
Using PIC16F628 Single Chip Microcomputer to Construct PVS Control System
  introduction   With the continuous optimization of surface mount technology (SMT) and the rapid development of chip component manufacturing technology, the application of chip mounters in the electronics manufacturing industry has become increasingly prominent. The CM402 high-speed chip mounter is developed and prod
[Microcontroller]
Using PIC16F628 Single Chip Microcomputer to Construct PVS Control System
Design of reading data from 24C02 to digital tube display based on PIC microcontroller
The test function is to reset the microcontroller once, automatically read the data from 24C02 to the digital tube display, then add 1 to the value and write it into 24C02. Finally, the data in the digital tube is the number of times the machine is turned on, which has certain practical significance. ; The 24C02 use
[Microcontroller]
Design of reading data from 24C02 to digital tube display based on PIC microcontroller
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号