PIC16F877A C Programming
PIC16F877A C Programming
PIC16F877A C Programming
PIC16F877 Microcontroller
C Programming
www.microchip.com
All of these features make it ideal for more advanced level A/D
applications in automotive, industrial, appliances and consumer
applications.
05/16/24 ECE331 (KEH) 2
There are three
Choices of
PIC16F877
packages… Note
that the 40-pin DIP
package is very
wasteful of space,
but it is IDEAL for
breadboarding
prototype circuits!
We need to THANK
Microchip for
retaining this
outdated (but VERY
helpful package)!
Likewise, you will see in datasheet Section 2.2.2.2 that there is an RBPU\
(Port B pull-up enable) bit that can be CLEARED in the OPTION register
to allow PORTB to have internal pull-ups enabled on the PORTB input
pins. This is quite handy if one wants to interface an X-Y keyswitch matrix
to PORTB! Other port inputs besides PORTB must be externally pulled
up.
Another caveat that was already mentioned, but bears repeating, involves
the use of PORTA for general-purpose digital I/O. The ADCON1 register
must be configured to permit various PORTA inputs to be used for
general-purpose parallel I/O. Be sure to consult the PIC16F877A data
sheet before using any of the PORTA pins as general-purpose I/O.
R1
SW 1
10 K
S W P U S H B U TTO N
P IC 16F877A D1
2 15
3 R A0/AN 0 R C 0 / T1 O S O / T1 C K I 16
4 R A1/AN 1 R C 1 / T1 O S I / C C P 2 17 R3
R A2/AN 2/VR EF - R C 2/C C P1
ICD-2 Connector 5
6 R A3/AN 3/VR EF +
R A 4 / T0 C K I
R C 3/SC K/SC L
R C 4/SD I/SD A
18
23
LED
220 O hm s
Not Used 7
R A5/AN 4/SS R C 5/SD O
24
6 (WHI) R C 6 / TX/ C K
25
33 26
R B0/IN T R C 7 / R X/ D T
Program Clock 34
R B1
5 (BLK) 35
R B2 R D 0/PSP0
19
36 20
R B3/PG M R D 1/PSP1
Program Data 37
R B4 R D 2/PSP2
21
4 (RED) 38
R B5 R D 3/PSP3
22
39 27
R B6/PG C R D 4/PSP4
Ground C1 C R Y S TA L 40
R B7/PG D R D 5/PSP5
28
3 (GRN) R D 6/PSP6
29
13 30
O SC 1/C LKIN R D 7/PSP7
+5V 22 PF Y1 14
O SC 2/C LKO U T
2 (YEL) R E0/R D /AN 5
8
1 9
M C L R / V P P / TH V R E1/W R /AN 6 10
C2 22 PF 11 R E2/C S/AN 7
VD D
1 (BLU) Reset 32
VD D VSS VSS
0.1 U F C3
Fastest Speed
1 for all 10 time slots
100% Vcc