It belongs to the peripheral interrupt system, so it is a low-priority interrupt when used, and many registers need to be opened: peripheral interrupt enable, timer interrupt 1 enable...
Keywords:PIC
Reference address:PIC timer interrupt 1 (peripheral interrupt)
#include
__CONFIG(1,XT); //Crystal oscillator is external 4M
__CONFIG(2,WDTDIS); //Watchdog off
__CONFIG(4,LVPDIS); //Disable low voltage programming
#define uchar unsigned char
#define uint unsigned int
char shuma[10]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};
int count=0;
char sec=0;
//Interrupt function
void interrupt k(void)
{
if(TMR1IF==1) //Judge whether an interrupt occurs
{
TMR1IF=0;
TMR1H=0xff; //Note that the initial value must be reinstalled
TMR1L=0x06;
count++;
if(count==4000)
{
count=0;
sec++;
if(sec>9)
sec=0;
}
}
}
void display()
{
PORTD=shuma[sec];
}
void main(void)
{
ADCON1=0X06;
TRISD=0B00000000;
IPEN=0; //Disable interrupt priority
PEIE=1; //Enable all peripheral interrupts that are not disabled
T1CON=0x01; //Enable timer interrupt 1
TMR1IE=1; //Enable current timer interrupt 1
TMR1IF=0; //Software clears interrupt flag
TMR1H=0xff; //Must calculate manually, cannot be done by left shift, right shift, etc.
TMR1L=0x06; //Must calculate manually, cannot be done by shifting left or right, etc.
GIE=1; //Open general interrupt
while(1)
{
display();
}
}
Previous article:PIC timer interrupt 1 + external interrupt 0
Next article:PIC external interrupt INT0
- 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
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- Learn ARM development(15)
- Analysis of the application of several common contact parts in high-voltage connectors of new energy vehicles
- Wiring harness durability test and contact voltage drop test method
Guess you like
- [TI's Big Live Broadcast] Let's get started! For 30 yuan, let's play with the new MSP430 that helps eliminate smog, vertical and horizontal sensing and measurement
- HardFault location method and steps for smart microcontroller
- [ESP32-Audio-Kit Audio Development Board]-1. Installation of the development environment
- Filter Design in Embedded Development
- How to reuse the same module in Allegro software?
- sad
- (2) Based on STM32L4R9 MEMS sensor board (IKS01A3): project creation and testing
- Huawei base station equipment disassembly-power supply part
- Wireless connectivity
- High-Speed Signal Conditioning Product Selection Guide