Specifications
mikroElektronika | Free Online Book | PIC Microcontrollers | Chapter 1: PIC16F887 Microcontroller - Device Overview
pushed eight times, the ninth push overwrites the value that was stored with the first push. The tenth push overwrites the
second push and so on. Data overwritten in this way is not recoverable. In addition, the programmer cannot access these
registers for write or read and there is no Status bit to indicate stack overflow or stack underflow conditions. For that
reason, one should take special care of it during program writing.
Interrupt System
The first thing that the microcontroller does when an interrupt request arrives is to execute the current instruction and
then stop regular program execution. Immediately after that, the current program memory address is automatically
pushed onto the stack and the default address (predefined by the manufacturer) is written to the program counter. That
location from where the program continues execution is called the interrupt vector. For the PIC16F887 microcontroller,
this address is 0004h. As seen in Fig. 1-7 below, the location containing interrupt vector is passed over during regular
program execution.
Part of the program being activated when an interrupt request arrives is called the interrupt routine. Its first instruction is
located at the interrupt vector. How long this subroutine will be and what it will be like depends on the skills of the
programmer as well as the interrupt source itself. Some microcontrollers have more interrupt vectors (every interrupt
request has its vector), but in this case there is only one. Consequently, the first part of the interrupt routine consists in
interrupt source recognition.
Finally, when the interrupt source is recognized and interrupt routine is executed, the microcontroller reaches the
RETFIE instruction, pops the address from the stack and continues program execution from where it left off.
Fig.1-7 Interrupt System
How to use SFRs
You have bought the microcontroller and have a good idea how to use it...There is a long list of SFRs with all bits. Each of
them controls some process. All in all, it looks like a big control table with a lot of instruments and switches. Now you are
concerned about whether you will manage to learn how to use them all? You will probably not, but don’t worry, you don’t
have to! Such powerful microcontrollers are similar to a supermarkets: they offer so many things at low prices and it is
only up to you to choose. Therefore, select the field you are interested in and study only what you need to know.
Afterwards, when you completely understand hardware operation, study SFRs which are in control of it ( there are usually
a few of them). To reiterate, during program writing and prior to changing some bits of these registers, do not forget to
select the appropriate bank. This is why they are listed in the tables above.
Previous Chapter | Table of Contents | Next Chapter
http://www.mikroe.com/en/books/picmcubook/ch1/ (14 of 14)5/3/2009 11:31:25 AM