ATtiny15L
47
PORT B as General Digital I/O
The lower 5 pins in port B are equal when used as digital I/O pins.
PBn, General I/O pin: The DDBn bit in the DDRB register selects the direction of this pin, if DDBn is set (one), PBn is con-
figured as an output pin. If DDBn is cleared (zero), PBn is configured as an input pin. If PORTBn is set (one) when the pin
is configured as an input pin, the MOS pull-up resistor is activated. To switch the pull-up resistor off, the PORTBn has to be
cleared (zero) or the pin has to be configured as an output pin. Pull-ups for all ports can be disabled also by setting PUD-bit
in the MCUCR register.
n: 4,3…0, pin number.
On ATtiny15L, PB5 is input or open-drain output. Because this pin is used for 12V programming, there is no ESD protection
diode limiting the voltage on the pin to V
CC
+ 0.5V. Thus, special care should be taken to ensure that the voltage on this pin
does not rise above V
CC
+ 1V during normal operation. This may cause the MCU to reset or enter programming mode
unintentionally.
All Port B pins are connected to a pin change detector that can trigger the pin change interrupt. See “Pin Change Interrupt”
on page 21 for details.
Alternate Functions of Port B
The alternate pin functions of Port B are:
•
RESET - PORT B, Bit 5
When the RSTDISBL fuse is unprogrammed, this pin serves as external reset. When the RSTDISBL fuse is programmed,
this pin is a general input pin or a open-drain output pin. If DDB5 is cleared (zero), PB5 is configured as an input pin. If
DDB5 is set (one), the pin is a open-drain output.
•
SCK/INT0/T0 - PORT B, Bit 2
In serial programming mode, this pin serves as the serial clock input, SCK.
In normal mode, this pin can serve as the external interrupt0 input. See the interrupt description for details on how to
enable this interrupt. Note that activity on this pin will trigger the interrupt even if the pin is configured as an output.
In normal mode, this pin can serve as the external counter clock input. See the Timer/Counter0 description for further
details. If external timer/counter clocking is selected, activity on this pin will clock the counter even if it is configured as an
output.
•
MISO/OC1A/AIN1 - PORT B, Bit 1
In serial programming mode, this pin serves as the serial data output, MISO.
In normal mode, this pin can serve as Timer/Counter1 output compare match output (OC1A). See the Timer/Counter1
description for further details, and how to enable the output. The OC1A pin is also the output pin for PWM mode timer
function.
This pin also serves as the negative input of the on-chip analog comparator.
•
MOSI/AIN0/AREF - PORT B, Bit 0
In serial programming mode, this pin serves as the serial data input, MOSI.
In normal mode, this pin also serves as the positive input of the on-chip analog comparator.
This pin also serves as the positive input of the on-chip analog comparator.
In ATtiny15L, this pin can be chosen to be the reference voltage for the ADC. Refer to the section “The Analog to Digital
Converter” for details.
Table 21.
DDBn Effects on Port B Pins
DDBn
PORTBn
I/O
Pull-up
Comment
0
0
Input
No
Tri-state (Hi-Z)
0
1
Input
No
PUD bit in the MCUCR register is set.
0
1
Input
Yes
PBn will source current if ext. pulled low.
PUD bit in the MCUCR register is cleared.
1
0
Output
No
Push-pull Zero Output
1
1
Output
No
Push-pull One Output