Documente Academic
Documente Profesional
Documente Cultură
16F877A
Input/Output
• Pins can be assigned as analog input,
digital input or digital output
Pinout
Port A
Port A
Has 6 pins
RegisterAbit0 to RegisterAbit5 (RA0-RA5)
AnalogInput0 to AnalogInput4 (AN0-AN4)
RA0-RA5 can be used as digital inputs
RA0-RA5 can be used as digital outputs
AN0-AN4 can be used as analog inputs
Port B
Port B
Has 8 pins
RB0-RB7 can be used as digital
inputs
RB0-RB7 can be used as digital
outputs
External interrupt pin on RB0
External port interrupt on RB4-RB7
Port C
Port C
Has 8 pins
RC0-RC7 can be used as digital inputs
RC0-RC7 can be used as digital outputs
PWM (Pulse Width Modulation) is possible
on RC1 AND RC2
Port C contains USART (Universal
Synchronous - Asynchronous Receiver
Transmitter) for serial communication
Port D
Port D
Has 8 pins
RD0-RD7 can be used as digital
inputs
RD0-RD7 can be used as digital
outputs
Port E
Port E
Has 3 pins
RE0-RE2 can be used as digital
inputs
RE0-RE2 can be used as digital
outputs
AN5-AN7 can be used as analogue
inputs
Port Map
Internal Connection
EPROM
This timer interrupt is used to provide the PICmicro with exact timing info.
It is clocked by the system clock or by an external clock on RA4.
This system clock runs exactly 4 times slower than the external oscillator
clock.
Either the external clock or the system clock can be divided by 1, 2, 4 or 8,
16, 32, 64, 128, or by 256 by configuring the Prescaler of TMR0 in
Flowcode.
This divided clock triggers TMR0 to increment the TMR0 register.
This TMR0 register is an 8-bit register and will have an overflow when it
reaches 256.
he exact moment when this overflow occurs, TMR0 generates an interrupt
and the TMR0 register is set back to 0.
This TMR0 Interrupt will stop the main program immediately and start up the
TMR0 Macro.
After the TMR0 Macro is finished, the main program goes further where it
had left before.
Example
Example:
External clock oscillator =
XTAL : 19.660.800Hz
System Clock = /4
: 4.915.200 Hz
Set prescaler to 256 =
/256 : 19200 Hz
Overflow when TMR0 = 256 = /256
: 75 Hz
RB0 External Interrupt