In this case we will read out the pins from one whole port and write the read value to another port.
Setup steps
Example code
#define IN_PORT  IOPORT_PORTA
#define OUT_PORT IOPORT_PORTB
#define MASK     0x00000060
Workflow
- It's useful to give the ports symbolic names:
#define IN_PORT  IOPORT_PORTA
#define OUT_PORT IOPORT_PORTB
 
- Note
 - The port names differ between architectures:
- MEGA_RF, MEGA and XMEGA: There are predefined names for ports: IOPORT_PORTA, IOPORT_PORTB ...
 
- UC3: Use the index value of the different IO blocks: 0, 1 ...
 
- SAM: There are predefined names for ports: IOPORT_PIOA, IOPORT_PIOB ...
 
 
 
 
- Also useful to define a mask for the bits to work with:
 
- Initialize the ioport service. This typically enables the IO module if needed.
 
- Set one of the ports as input:
 
- Set the other port as output:
 
Usage steps
Example code
Workflow
- Define a variable for port date storage:
 
- Read out from one port:
 
- Put the read data out on the other port: