17.3.2.4 Multi-Pin Configuration
The multi-pin configuration function is used to configure multiple
PORT pins in one operation. The wanted pin configuration is first written to
the PORTx.PINCONFIG register, followed by a register write, with the
selected pins to modify. This allows changing the configuration
(PORTx.PINnCTRL) for up to eight pins in one write.
Tip: The PORTx.PINCONFIG
register is mirrored on all ports, which allows the use of a single
setting across multiple ports. The PORTx.PINCTRLUPD/SET/CLR
registers are not mirrored and need to be applied to each
port.
For the multi-pin configuration, PORT pins can be configured and
modified by writing to the following registers.
Register | Description |
---|---|
PORTx.PINCONFIG | PINnCTRL (ISC, PULLUPEN and INVEN) setting to prepare simultaneous configuration of multiple PINnCTRL registers |
PORTx.PINCTRLUPD | Writing a ‘1 ’
to bit n in the PINCTRLUPD register will copy the
PINCONFIG register content to the PINnCTRL
register |
PORTx.PINCTRLSET(1) | Writing a ‘1 ’
to bit n in the PINCTRLSET register will set the
individual bits in the PINnCTRL register,
according to the bits set to ‘1 ’
in the PINCONFIG register |
PORTx.PINCTRLCLR(2) | Writing a ‘1 ’ to bit n in
the PINCTRLCLR register will clear the individual
bits in the PINnCTRL register, according to the
bits set to ‘1 ’ in the PINCONFIG
register |
Note:
- Using PINCTRLSET to configure non-zero ISC bit fields will result in a bitwise OR with the PINCONFIG and PINnCTRL registers, which may give an unexpected setting.
- Using PINCTRLCLR to configure non-zero ISC bit fields will result in a bitwise inverse AND with the PINCONFIG and PINnCTRL registers, which may give an unexpected setting.
The following code snippet demonstrates how to configure multiple PINnCTRL registers, of multiple ports.
Important: Because the PINCONFIG register is mirrored across all the
ports, it is enough to only write it once, for PORT A, in this
example.
PORTA.PINCONFIG = PORT_ISC_INPUT_DISABLE_gc; /* The setting to load to the PINnCTRL registers */ PORTA.PINCTRLUPD = 0xff; PORTB.PINCTRLUPD = 0xff; PORTC.PINCTRLUPD = 0xff; PORTD.PINCTRLUPD = 0xff; PORTE.PINCTRLUPD = 0xff;