Professional Documents
Culture Documents
Using The PORTB Interrupt On Change As An External Interrupt
Using The PORTB Interrupt On Change As An External Interrupt
AN566
USING A PORTB INPUT FOR AN
Author: Mark Palmer
Microchip Technology Inc. EXTERNAL INTERRUPT
The interrupt source(s) cannot simply be directly
INTRODUCTION connected to the PORTB pins, and expect an interrupt
to occur the same as on the interrupt (INT) pin. To
The PICmicro™ families of RISC microcontrollers are develop the microcontrollers hardware/software to act
designed to provide advanced performance and a as an interrupt by an external signal, we must know the
cost-effective solution for a variety of applications. To characteristics of the external signal. After we know
address these applications, there is the PIC16CXXX this, we can determine the best way to structure the
microcontroller family of products. This family has program to handle this signal. The characteristics that
numerous peripheral and special features to better we need to consider when developing the interrupt
address user applications. include:
The feature this application note will focus on is the 1. The rising edge and falling edges.
Interrupt on Change of the PORTB pins. This “interrupt 2. The pulse width of the interrupt trigger (high time
on change” is triggered when any of the RB7:RB4 pins, / low time).
configured as an input, changes level. When this inter-
rupt is used in conjunction with the software It is easy to understand the need of knowing about
programmable weak internal pull-ups, a direct interface which edge triggers the interrupt service routine for the
to a keypad is possible. This is shown in application external interrupt. This allows one to ensure that the
note AN552, Implementing Wake-up on Key Stroke. interrupt service routine is only entered for the desired
Another way to use the “interrupt on change” feature edge, with all other edges ignored. Not so clear is the
would be as additional external interrupt sources. This pulse width of the interrupt’s trigger. This characteristic
allows PIC16CXXX devices to support multiple external helps determine the amount of additional overhead that
interrupts, in addition to the built-in external interrupt on the software routine may need.
the INT pin.
This application note will discuss some of the issues in
using PORTB as additional external interrupt pins, and
will show some examples. These examples can be eas-
ily modified to suit your particular needs.
RBx
RBx
Falling Edge
Triggers “False” Interrupt
• The PICmicro family meets the specifications contained in the Microchip Data Sheet.
• Microchip believes that its family of PICmicro microcontrollers is one of the most secure products of its kind on the market today,
when used in the intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowl-
edge, require using the PICmicro microcontroller in a manner outside the operating specifications contained in the data sheet.
The person doing so may be engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable”.
• Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of
our product.
If you have any further questions about this matter, please contact the local sales office nearest to you.
• The PICmicro family meets the specifications contained in the Microchip Data Sheet.
• Microchip believes that its family of PICmicro microcontrollers is one of the most secure products of its kind on the market today,
when used in the intended manner and under normal conditions.
• There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowl-
edge, require using the PICmicro microcontroller in a manner outside the operating specifications contained in the data sheet.
The person doing so may be engaged in theft of intellectual property.
• Microchip is willing to work with the customer who is concerned about the integrity of their code.
• Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as “unbreakable”.
• Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of
our product.
If you have any further questions about this matter, please contact the local sales office nearest to you.
01/18/02