Professional Documents
Culture Documents
PIC16F877
PIC16F877 (Cont.)
CLOCK
PIC needs a clock to operate the chip.
Each instruction cycle requires 4 clock
cycles
20MHz clock (50ns clock) ---> 200ns
instruction cycle
Clock Oscillator: RC
RC mode is simple and inexpensive if application
The external capacitor can be eliminated, but Microchip warns that the
frequency can vary widely and change often. They recommend at least
20pF of external capacitance for anything resembling stable operation.
CpE 112 : Klinkhachorn
The 3 modes are very similar except for the amount of drive supplied to the
crystal
An
* http://www.botkin.org/dale/PICarch.htm
http://www.mtron.com/applinf.htm
CpE 112 : Klinkhachorn
temperature characteristics
of quartz crystal are
primarily determined by the
orientation angle at which
the quartz wafers are cut
from a given bar of quartz.
These properties are
dependent on the reference
directions within the
crystals.
AT and XT cut are the most
common use
*
http://www.mtron.com/applinf.htm
CpE 112 : Klinkhachorn
http://www.mtron.com/applinf.htm
CpE 112 : Klinkhachorn
http://www.mtron.com/applinf.htm
CpE 112 : Klinkhachorn
http://www.mtron.com/applinf.htm
* http://www.botkin.org/dale/PICarch.htm
Clock Oscillator:
Capacitor selection for X-tal Osc.
Clock Oscillator:
Capacitor selection for ceramic resonator
RESET/START UP Sequence
Time-Out sequence on Power UP (MCLR/ tied to Vdd)
1.2-1.7V
72 ms.
RESET/START UP
Power-On Reset (POR)
Pulse is generated on-chip when VDD rise is detected (1.2-1.7V)
MCLR/ must be tie directly (or through a resistor) to VDD
100
MCLR/
RES ET
PIC
RESET/START UP
Brown-Out Reset (BOR)
If Vdd falls below VBOR (about 4 volts) for longer than TBOR
(100us), the brown out circuit will reset the device
Device will remain in brown-out reset until Vdd rises above VBOR then
the normal start up sequence begins
RESET
Simplified Block Diagram of On-Chip Reset Circuit
I/O Ports
Input/Output Ports
Some pins for these I/O ports are multiplexed with an
register
Setting a TRISA bit (=1) will make the corresponding
PORTA pin an input
Clearing a TRISA bit (=0) will make the corresponding
PORTA pin an output
PORTA
PORTA
PORTA Initialization
EXAMPLE
bcf STATUS,RP0
bcf STATUS, RP1
clrf PORTA
;
; Bank0
;Initialize PO RTA by
; clearing output
; data latches
bsf STATUS, RP0
; Select Bank 1
m ovlw 0x06
; Configure all pins
m ovwf ADCON1
; as digital inputs
m ovlw 0xCF
; Value used to
;initialize data
; direction
m ovwf TRISA ; Set RA<3:0> as inputs
; RA<5:4> as outputs
; TRISA<7:6> are always
; read as 0.
CpE 112 : Klinkhachorn
TRIS Instruction ?
The TRIS instruction is currently supported on
TRIS Instruction ?
register
Setting a TRISB bit (=1) will make the corresponding
PORTB pin an input
Clearing a TRISB bit (=0) will make the corresponding
PORTB pin an output
PORTB
RB0:RB3
PORTB
RB4:RB7
register
Setting a TRISC bit (=1) will make the corresponding
PORTC pin an input
Clearing a TRISC bit (=0) will make the corresponding
PORTC pin an output
PORTC
RC<0:2>, <5:7>
PORTC
RC<3:4>
PORTD
I/O PORT MODE
PORTE
I/O PORT MODE
PORTE
Parallel Slave Port
- SMART PORT!
Address Bus
P
O
RD R
T
WR E
CS
Decoder
PIC
PSP
Computer
?
SMART I/O
PORTD
IOW
Control Bus
CpE 112 : Klinkhachorn