Anda di halaman 1dari 7

INTERRUPTS

The PIC16F87X has 14 sources of interrupt


 External interrupt RB0/INT pin
 TMR0 overflow interrupt
 PORTB change interrupts (pins RB7:RB4)
 Comparator Change Interrupt
 Parallel Slave port Interrupt
 USART Interrupt
 Receive Interrupt
 Transmit Interrupt
 ADC complete Interrupt
 LCD Interrupt
 Data EEPROM write complete interrupt
 TIMER1 overflow Interrupt
 TIMER2 overflow Interrupt
 CCP Interrupt
 SSP Interrupt
INTCON - Interrupt Control Reg

 bit 7 GIE: Global Interrupt Enable bit


1 = Enables all interrupts 0 = Disables all interrupts
 bit 6 PEIE: Peripheral Interrupt Enable bit
1 = Enables peripheral interrupts 0 = Disables all peripheral interrupts
 bit 5 T0IE: TMR0 Overflow Interrupt Enable bit
1 = Enables the TMR0 interrupt, 0 = Disables the TMR0 interrupt
 bit 4 INTE: RB0/INT External Interrupt Enable bit
1 = Enables RB0/INT external intpt, 0 = Disables the RB0/INT
 bit 3 RBIE: RB Port Change Interrupt Enable bit
1 = Enables the RB port change interrupt 0 = Disables the RB intprt
 bit 2 T0IF: TMR0 Overflow Interrupt Flag bit
1 = TMR0 register has overflowed 0 = TMR0 register did not overflow
 bit 1 INTF: RB0/INT External Interrupt Flag bit
1 = RB0/INT external intpt occurred 0 = The RB0/INT did not occur
 bit 0 RBIF: RB Port Change Interrupt Flag bit
 TO GENERATE INTERRRUPT
 INCLUDE<P16F877.INC>

 ORG 0X00

 REG EQU 0X20


 REG1 EQU 0X21

 GOTO MAIN

 ORG 0X04
 BCF INTCON,T0IF
 RETFIE

 MAIN CLRF STATUS


 CLRF TMR0
 BSF STATUS,5
 CLRF OPTION_REG
 BCF STATUS,5
 MOVLW 0XE0
 MOVWF INTCON
 NOP
 BTFSS INTCON,T0IF
 GOTO $-1
 BCF INTCON,T0IF
 GOTO MAIN
 END
PERIPHERAL INTERRUPT

 PIE1 , PIR1 , PIE2 , PIR2

 The peripheral interrupt flags are contained in the special


function registers, PIR1 and PIR2.

 The corresponding interrupt enable bits are contained in


special function registers, PIE1 and PIE2

 The peripheral interrupt enable bit is contained in special


function register INTCON.

 When an interrupt is responded to, the GIE bit is cleared


to disable any further interrupt, the return address is
pushed onto the stack and the PC is loaded with 0004h.
 PIE REGISTER
 BIT PSPIE:Parallel Slave Port Read/Write Interuppt Enable Bit
 1=Enables the PSP read/write interuppt 0=disenables the PSP read/write interuppt
 BIT ADIE: A/D Converter interuppt Enable bit
 1=enables the A/D Interuppt 0=Disenables the A/D Interuppt
 Bit RCIE:USART RECEIVE INTERUPPT ENABLE Bit
 1=enables the USART receive interuppt 0=disables the USART receive interuppt
 BIT TXIE:USART Transmit Interuppt Enable bit
 1=enables the USART transmit interuppt 0=disables the USART transmit interuppt
 BIT SSPIE:Synchronous Serial Port Interrupt enable bit
 1=Enables the SSP Interrupt 0=Disables the SSP Interrupt
 BIT CCP1IE:CCP1 Interrupt Enable bit
 1=Enables the CCP1 Interrupt 0=disables the CCP1 Interrupt
 Bit TMR2IE:TMR2 to PR2 Match interrupt Enable Bit
 1=enables the TMR2 to PR2 Match interrupt 0=disables the TMR2 to PR2 Match interrupt
 Bit TMR1IE:TMR1 OVERFLOW iNTERRUPT Enable bit
 1=enables the TMR1 overflow interrupt 0=disables the TMR1 overflow interrupt
 Bit CCP2IE:CCP2 Interrupt Enable bit
 1=Enables the CCP1 Interrupt 0=disables the CCP1 Interrupt
 Bit ADCIE:Slope A/D Converter comparator Trip Interrupt Enable bit
 1=Enables the Slope A/D Interrupt 0=disables the Slope A/D interrupt
 Bit OVFIE:Slope A/D TMR Overflow Interrupt Enable Bit
 1=enables the Slope A/D TMR Overflow Interrupt 0=disables the Slope A/D TMR Overflow Interrupt
 Bit EEIE:EE Write Complete interrupt enable bit
 1=Enables the EE Write complete interrupt 0=disables the EE write complete interrupt
 Bit LCDIE:LCD Interrupt Enable bit
 1=Enable the LCD Interrupt 0=disables the LCD Interrupt
 Bit CMIE:Comparator Interrupt Enable bit
 1=Enables the comparator interrupt 0=disables the comparator interrupt
 PIR REGISTER
 Bit TMR1IF:TMR1 Overflow Interrupt Flag bit
 1=TMR1 register overflowed 0=TMR1 register did not overflow
 Bit TMR2IF:TMR2 to PR2 Match Interrupt Flag bit
 1=TMR2 to PR2 Match occurred 0=No TMR2 to PR2 match occurred
 Bit CCP1IF:CCP1 Interrupt Flag bit Capture Mode
 1=A TMR1 Register capture occurred 0= No TMR1 Register capture occurred
 Compare mode
1= A TMR1 register compare match occurred 0=No TMR1 register compare match occurred
 PWM Mode
 Unused in this mode.
 Bit SSPIF: Synchronous Serial Port Interrupt Flag bit
 1=The transmission/reception is complete 0=Waiting to transmit/receive.
 Bit RCIF :USART Receive Interrupt Flag bit
 1=The USART receive buffer,RCREG,is full 0=The USART receive buffer is empty.
 Bit TXIF: USART Transmit Interrupt Flag bit
 1=The USART transmit buffer,TXREG,is empty 0=The USART transmit buffer is full.
 Bit ADIF: A/D Converter Interrupt Flag bit.
 1=An A/D conversion completed 0=The A/D conversion is not complete
 Bit ADCIF:Slope A/D Converter Comparator Trip Interrupt Flag bit
 1=An A/D Conversion completed 0=The A/D conversion is not complete
 Bit OVFIF:Slope A/D TMR Overflow Interrupt Flag bit
 1=Slope A/D TMR Overflowed 0=Slope A/D TMI did not overflow
 Bit PSPIF:Parallel Slave Port Read /Write Interrupt Flag bit
 1=A read or a write operation has taken place 0=No read or write has occurred.
 Bit EEIF:EE Write Complete Interrupt Flag bit
 1=The data EEPROM write operation is complete 0=The data EEPROM write operation is not complete
 Bit LCDI:LCD Interrupt Flag bit
 1=LCD Interrupt has occurred 0= LCD Interrupt has not occurred
 Bit CMIF:Comparator Interrupt Flag bit
 1=Comparator input has changed 0=Comparator input has not changed

Anda mungkin juga menyukai