Multipin Configuration

The multipin configuration function is used to configure the 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. The following code snippet shows the pin configuration for PORTA:

/* Pin configuration - inverted I/O enabled, Pull-up enabled, interrupt sensing on rising edge */
	PORTA.PIN7CTRL = PORT_INVEN_bm | PORT_PULLUPEN_bm | PORT_ISC1_bm; 
	PORTA.PIN5CTRL = PORT_INVEN_bm | PORT_PULLUPEN_bm | PORT_ISC1_bm; 
	PORTA.PIN2CTRL = PORT_INVEN_bm | PORT_PULLUPEN_bm | PORT_ISC1_bm; 
	PORTA.PIN0CTRL = PORT_INVEN_bm | PORT_PULLUPEN_bm | PORT_ISC1_bm;

The previous code can be replaced, using the multipin configuration feature, with:

/* Pin configuration - inverted I/O enabled, Pull-up enabled, interrupt sensing on rising edge */
	PORTA.PINCONFIG  = PORT_INVEN_bm | PORT_PULLUPEN_bm | PORT_ISC1_bm;/* Update PINxCTRL for pins PA7, PA5, PA2 and PA0 */  			
	PORTA.PINCTRLUPD = PIN7_bm | PIN5_bm | PIN2_bm | PIN0_bm;