DM163045 Microchip Technology, DM163045 Datasheet - Page 52

no-image

DM163045

Manufacturer Part Number
DM163045
Description
PICDEM Lab Development Kit (with PICkit 3) General Purpose
Manufacturer
Microchip Technology
Series
PICDEM™r
Type
MCUr
Datasheet

Specifications of DM163045

Contents
Board, PIC kit 3
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
For Use With/related Products
PIC Micro® MCU

Available stocks

Company
Part Number
Manufacturer
Quantity
Price
Part Number:
DM163045
Manufacturer:
MICROCHIP
Quantity:
12 000
PICDEM
DS41369A-page 48
TM
3.4.5
3.4.5.1
To configure the peripherals used in this lab, the following registers are used:
1. OPTION Register: OPTION (Register 2-2 in Section 2 of the PIC16F690 Data
2. Interrupt Control Register: INTCON (Register 2-3 in Section 2 of the PIC16F690
3.4.5.2
This lab expands upon Lab 5 by adding an interrupt that will occur each time the push
button connected to the RA2 pin is pressed.
As mentioned, polling a bit is heavily reliant on a number of factors such as the size of
the firmware and the timing of the software control loop. Polling does have its uses.
However, there may be times when an event, such as pressing a push button, requires
immediate attention. This is where the interrupt comes in. As the name implies, an
interrupt acts as a sort of alarm. When the Central Processing Unit receives an inter-
rupt, it immediately stops what it is doing, saves where in the code it was before the
interrupt, performs code or firmware defined by the user in the event of an interrupt
called an Interrupt Service Routine (ISR), and then returns to the previous task it was
performing prior to the interrupt.
So, why not use interrupts all the time? The answer is mainly cost. In order to
implement an interrupt for a specific function, the user may need to purchase a micro-
controller with a peripheral that accommodates the interrupt. This increases the cost of
the application. In some cases, polling a bit may be the way to go. Other cases may
require the interrupt thereby justifying the added cost of a particular peripheral.
The RA2 pin associated with the PORTA register features an external edge-triggered
interrupt capability (note the INT designation on the PIC16F690 Pin Diagram in Table
5 of the data sheet). The interrupt is configurable to occur on either the rising-edge (i.e.,
signal on RA2 pin transitions from low-to-high) or the falling-edge (i.e., signal on RA2
pin transitions from high-to-low) of the voltage on the RA2 pin. If the selected edge tran-
sition is detected on RA2, the CPU then services the interrupt before returning to the
code it was executing prior to the interrupt. Referring again to Figure 3-12, the push
button connected to the RA2 pin is pulled high when not pressed. Therefore, the inter-
rupt will be configured to trigger on the high-to-low transition indicating a push button
press.
The INTCON register contains the enable (INTE) and flag (INTF) bits for the RA2
external interrupt. These bits indicate to firmware the condition that caused an interrupt
to occur. The other bits and accompanying registers are used for other peripheral
features on the microcontroller. The Global Interrupt Enable bit (GIE) is a sort of master
switch that allows interrupts, if individually enabled, to be used by the microcontroller.
The OPTION register features the Interrupt Edge Select (INTEDG) bit that will be used
to indicate the edge transition that will trigger an interrupt.
The software flowchart for this lab is shown in Figure 3-23.
Lab Development Board User’s Guide
- Selects the edge transition on RA2/INT that will trigger an interrupt.
- Enable interrupt functionality on the PIC16F690.
- Enables the RA2/INT external interrupt.
- Contains a flag that indicates the external interrupt has occurred.
Sheet)
Data Sheet)
Lab 6: Push Button Interrupt
NEW REGISTERS USED IN THIS LAB
OVERVIEW
© 2009 Microchip Technology Inc.

Related parts for DM163045