Microchip Technology megaAVR 0 Series Manual page 139

Hide thumbs Also See for megaAVR 0 Series:
Table of Contents

Advertisement

For best power consumption, disable the input of unused pins and pins that are used as analog inputs or
outputs.
Specific pins, such as those used for connecting a debugger, may be configured differently, as required
by their special function.
15.3.2
Operation
15.3.2.1 Basic Functions
registers. The base address of the register set for pin n is at the byte address PORT + 0x10 + � . The
Each I/O pin Pxn can be controlled by the registers in PORTx. Each pin group x has its own set of PORT
index within that register set is n.
To use pin number n as an output only, write bit n of the PORTx.DIR register to '1'. This can be done by
writing bit n in the PORTx.DIRSET register to '1', which will avoid disturbing the configuration of other pins
in that group. The n
Similarly, writing a PORTx.OUTSET bit to '1' will set the corresponding bit in the PORTx.OUT register to
'1'. Writing a bit in PORTx.OUTCLR to '1' will clear that bit in PORTx.OUT to zero. Writing a bit in
PORTx.OUTTGL or PORTx.IN to '1' will toggle that bit in PORTx.OUT.
To use pin n as an input, bit n in the PORTx.DIR register must be written to '0' to disable the output driver.
This can be done by writing bit n in the PORTx.DIRCLR register to '1', which will avoid disturbing the
configuration of other pins in that group. The input value can be read from bit n in register PORTx.IN as
long as the ISC bit is not set to INPUT_DISABLE.
Writing a bit to '1' in PORTx.DIRTGL will toggle that bit in PORTx.DIR and toggle the direction of the
corresponding pin.
15.3.2.2 Pin Configuration
The Pin n Configuration register (PORTx.PINnCTRL) is used to configure inverted I/O, pullup, and input
sensing of a pin.
All input and output on the respective pin n can be inverted by writing a '1' to the Inverted I/O Enable bit
(INVEN) in PORTx.PINnCTRL.
Toggling the INVEN bit causes an edge on the pin, which can be detected by all peripherals using this
pin, and is seen by interrupts or Events if enabled.
Pullup of pin n is enabled by writing a '1' to the Pullup Enable bit (PULLUPEN) in PORTx.PINnCTRL.
Changes of the signal on a pin can trigger an interrupt. The exact conditions are defined by writing to the
Input/Sense bit field (ISC) in PORTx.PINnCTRL.
When setting or changing interrupt settings, take these points into account:
If an INVEN bit is toggled in the same cycle as the interrupt setting, the edge caused by the
inversion toggling may not cause an interrupt request.
If an input is disabled while synchronizing an interrupt, that interrupt may be requested on re-
enabling the input, even if it is re-enabled with a different interrupt setting.
If the interrupt setting is changed while synchronizing an interrupt, that interrupt may not be
accepted.
Only a few pins support full asynchronous interrupt detection, see I/O Multiplexing and
Considerations. These limitations apply for waking the system from sleep:
©
2018 Microchip Technology Inc.
th
bit in the PORTx.OUT register must be written to the desired output value.
Datasheet Preliminary
®
megaAVR
0-Series
I/O Pin Configuration (PORT)
DS40002015A-page 139

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the megaAVR 0 Series and is the answer not in the manual?

This manual is also suitable for:

Atmega4808Atmega4809Atmega3208Atmega3209

Table of Contents