User manual

Table Of Contents
General Purpose Input/Output Labs
© 2009 Microchip Technology Inc. DS41369A-page 39
FIGURE 3-18: PICDEM LAB SCHEMATIC FOR GPIO INPUT LABS
The only change from the previous section is the inclusion of a push button connected
to RA2 with associated pull-up resistor.
3.4.4 Lab 5: Adding a Push Button
3.4.4.1 NEW REGISTERS USED IN THIS LAB
To configure the peripherals used in this lab, the following registers are used:
1. PORTA Register: PORTA (Register 4-1 in Section 4 of the PIC16F690 Data
Sheet)
- 8-bit bidirectional port
2. PORTA Tri-State Register: TRISA (Register 4-2 in Section 4 of the PIC16F690
Data Sheet)
- Configures corresponding bits in PORTA as either input or output
3.4.4.2 OVERVIEW
This lab expands upon Lab 4 by adding a push button interface to change the direction
of the sequential shift in the PORTC register.
Mechanical switches play an important and extensive role in practically every
computer, microprocessor and microcontroller application. Mechanical switches are
inexpensive, simple and reliable. However, switches can be very noisy electrically. The
apparent noise is caused by the closing and opening action that seldom results in a
clean electrical transition. The connection makes and breaks several, perhaps even
hundreds, of times before the final switch state settles. The problem is known as switch
bounce. Some of the intermittent activity is due to the switch contacts actually bouncing
off each other. Also, switch contacts are not perfectly smooth. As the contacts move
against each other, the imperfections and impurities on the surfaces cause the
electrical connection to be interrupted. The result is switch bounce. The consequences
U2
1
2
3
4
5
6
7
8
9
10
20
19
18
17
16
15
14
13
12
11
RC0
RC1
RC2
RC3
RC4
RC5
RC6
RC7
J9J8
R8
470
R4
470
R7
470
R6
470
R5
470
R3
470
R2
470
R1
470
LED8 LED7 LED6 LED4 LED3 LED2 LED1LED5
V
SS
V
SS
V
DD
R9
10K
SW1
RA2