18.3.2.4 Multi-Pin Configuration
The multi-pin configuration function can 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, allowing
changing the configuration (PORTx.PINnCTRL) for up to eight pins in one
write.
Tip: The
PORTx.PINCONFIG register is mirrored on all ports, allowing the use
of a single setting across multiple ports. The
PORTx.PINCTRLUPD/SET/CLR registers are not mirrored and
configurations must be written for 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, INLVL 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 nonzero ISC bit fields will result in a bitwise OR with the PINCONFIG and PINnCTRL registers and may give an unexpected setting.
- Using PINCTRLCLR to configure nonzero ISC bit fields will result in a bitwise inverse AND with the PINCONFIG and PINnCTRL registers and may give an unexpected setting.
The following code snippet demonstrates how to configure multiple PINnCTRL registers of several ports. Note that, 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;