Professional Documents
Culture Documents
AN566
Using the PortB Interrupt on Change as an External Interrupt
3-1
Using the PortB Interrupt on Change as an External Interrupt
Figure 1 shows the two cases for the interrupt signal An interrupt pulse with a small pulse width requires less
verses the time to complete the interrupt service routine. overhead than a wide pulse width. A small pulse width
The first waveform is when the signal makes the low-to- signal must be less then the minimum execution time of
high-to-low transitions before the interrupt service rou- the interrupt service routine, while a wide pulse width
tine has completed (interrupt flag cleared). When the must be greater then the maximum time through the
interrupt flag has been cleared the interrupt signal has interrupt service routine.
already returned to the inactive level. The next transition
Example 1 shows a single interrupt source on PortB
of the signal is due to another interrupt request. An
(RB7), which executes the interrupt service routine on a
interrupt signal with this characteristic will be called a
rising edge. The interrupt source has a small pulse
small pulse width signal. The second waveform is when
width. In this case since the interrupt pulse width is small,
the signal only makes the low-to-high transitions before
the pulse has gone high and then low again before PortB
the interrupt service routine has completed (interrupt
is read to end the mismatch condition. So when PortB is
flag cleared). The next transition (high-to-low) will return
read it will read a low signal and will again be waiting for
the interrupt signal to the inactive level. This will gener-
the rising edge transition.
ate a “false” interrupt, that will need to be cleared. Then
the following transition (low-to-high) will be a “true”
interrupt. An interrupt signal with this characteristic will
be called a wide pulse width signal.
RBx
RBx
Falling Edge
Triggers "False" Interrupt
3-2
Using the PortB Interrupt on Change as an External Interrupt
Example 2 shows a single interrupt source on PortB Example 3 shows a interrupt on change with the interrupt
(RB7), which executes the interrupt service routine on a source on PortB (RB7). This executes the interrupt
rising edge. The interrupt source has a wide pulse width. service routine on a both edges. The interrupt source
In this case since the interrupt pulse width is large, the must have a minimum pulse width to ensure that both
pulse is still high before PortB is read to end the mis- edges can be “seen”. The minimum pulse width is the
match condition. So when PortB is read it will read a high maximum time from the interrupt edge to the reading of
signal and will generate an interrupt on the next falling PortB and clearing the interrupt flag.
edge transition (which should be ignored).
3-3
Using the PortB Interrupt on Change as an External Interrupt
3-4
WORLDWIDE SALES & SERVICE
AMERICAS AMERICAS (continued) EUROPE
Corporate Office San Jose United Kingdom
Microchip Technology Inc. Microchip Technology Inc. Arizona Microchip Technology Ltd.
2355 West Chandler Blvd. 2107 North First Street, Suite 590 Unit 6, The Courtyard
Chandler, AZ 85224-6199 San Jose, CA 95131 Meadow Bank, Furlong Road
Tel: 602 786-7200 Fax: 602 786-7277 Tel: 408 436-7950 Fax: 408 436-7955 Bourne End, Buckinghamshire SL8 5AJ
Technical Support: 602 786-7627 ASIA/PACIFIC Tel: 44 0 1628 851077 Fax: 44 0 1628 850259
Web: http://www.mchip.com/microhip France
Hong Kong
Atlanta Arizona Microchip Technology SARL
Microchip Technology 2 Rue du Buisson aux Fraises
Microchip Technology Inc. Unit No. 3002-3004, Tower 1
500 Sugar Mill Road, Suite 200B 91300 Massy - France
Metroplaza Tel: 33 1 69 53 63 20 Fax: 33 1 69 30 90 79
Atlanta, GA 30350 223 Hing Fong Road
Tel: 770 640-0034 Fax: 770 640-0307 Germany
Kwai Fong, N.T. Hong Kong
Boston Tel: 852 2 401 1200 Fax: 852 2 401 3431 Arizona Microchip Technology GmbH
Microchip Technology Inc. Gustav-Heinemann-Ring 125
Korea
5 Mount Royal Avenue D-81739 Muenchen, Germany
Microchip Technology Tel: 49 89 627 144 0 Fax: 49 89 627 144 44
Marlborough, MA 01752 168-1, Youngbo Bldg. 3 Floor
Tel: 508 480-9990 Fax: 508 480-8575 Italy
Samsung-Dong, Kangnam-Ku,
Chicago Seoul, Korea Arizona Microchip Technology SRL
Microchip Technology Inc. Tel: 82 2 554 7200 Fax: 82 2 558 5934 Centro Direzionale Colleoni
333 Pierce Road, Suite 180 Palazzo Pegaso Ingresso No. 2
Singapore
Itasca, IL 60143 Via Paracelso 23, 20041
Microchip Technology Agrate Brianza (MI) Italy
Tel: 708 285-0071 Fax: 708 285-0075 200 Middle Road
Dallas Tel: 39 039 689 9939 Fax: 39 039 689 9883
#10-03 Prime Centre
Microchip Technology Inc. Singapore 188980 JAPAN
14651 Dallas Parkway, Suite 816 Tel: 65 334 8870 Fax: 65 334 8850 Microchip Technology Intl. Inc.
Dallas, TX 75240-8809 Taiwan Benex S-1 6F
Tel: 214 991-7177 Fax: 214 991-8588 Microchip Technology 3-18-20, Shin Yokohama
Dayton 10F-1C 207 Kohoku-Ku, Yokohama
Microchip Technology Inc. Tung Hua North Road Kanagawa 222 Japan
35 Rockridge Road Taipei, Taiwan, ROC Tel: 81 45 471 6166 Fax: 81 45 471 6122
Englewood, OH 45322 Tel: 886 2 717 7175 Fax: 886 2 545 0139
Tel: 513 832-2543 Fax: 513 832-2841 9/22/95
Los Angeles
Microchip Technology Inc.
18201 Von Karman, Suite 455
Irvine, CA 92715
Tel: 714 263-1888 Fax: 714 263-1338
New York
Microchip Technology Inc.
150 Motor Parkway, Suite 416
Hauppauge, NY 11788
Tel: 516 273-5305 Fax: 516 273-5335