Sunday, March 2, 2008

Knowing pic16f877 Interrupt Registers





<<<Previous Tutorial Next Tutorial>>>

INTERRUPTS IN 16F877A

The interrupt sources in PIC can be broadly classified into .
1.External interrupt
2.Internal interrupts .

There are totally 14 sources of interrupts in PIC16F877A .
  1. Timer0 overflow interrupt
  2. Timer 1 interrupt
  3. Timer 2 interrupt
  4. Capture compare interrupt ccp1.
  5. Capture compare interrupt ccp2.
  6. Comparator Interrupt
  7. USART Transmitter interrupt
  8. USART Receiver Interrupt
  9. Synchronous Serial Port interrupt
  10. EEPROM Write Interrupt
  11. Analog to Digital Converter interrupt
  12. Parallel slave port read write interrupt
  13. Bus collision interrupt
  14. External interrupt (RB0/INT0)
Starting with the registers .
The global register for the interrrupt is INTCON .The following tables show you the individual bits .














GIE

PEIE

TOIE

INTE

RBIE

TOIF

INTF

RBIF



The description of the individual bits are given below .The status of different interrupts when set as o and 1 .


























































BIT

NAME

WHEN SET 1

WHEN SET O

GIE

Global interrupt bit

Enable all

Disable all

PEIE

Peripheral interrupt enable bit

Enable all unmaskable peripheral
interrupts

Disable all
peripheral interrupts

TOIE

Timer 0 overflow interrupt enable bit

Enable

Disable

INTE

RB0/INT external interrupt
enable bit

Enable

Disable

RBIE

RB port change interrupt enable bit

Enable

Disable

TOIF

Timer 0 overflow interrupt flag

TMR0 reg overflows
































INTF

RB0/INT external interrupt flag

External interrupt occurs

No interrupt

RBIF

RB port change interrupt flag bit

One line changes its state from RB7 to RB4

No line changes


The first five bits are configuration bits and the next 3 lower bits are FLAGS .That will be set as 1 when the corresponding interrupt occours .It is the programmers responsiblity to clear those bits .It wont be cleared automatically .Its for the reson because if another interrupt occours while processing the previous interrupt it will lead to chaos .So the task is given to the programmer to clear the bits .



In addition to INTCON reg peripheral interrupt also has 4 more reg PIE1 , PIE2 corresponding to PIEX and PIR1 and PIR2 coressponding to PIRX.Let us see these registers in the next tutorials .







<<<Previous Tutorial Next Tutorial>>>














No comments: